BList: Allocate lazily.
Rather than allocating a block in the constructor, just wait to do it until we actually need to add items to the list. This saves over 200,000 allocations when running "pkgman search" alone. Change-Id: Ia6a21b963efded2bb4973edc2ba22ff026e01737 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8630 Tested-by: Commit checker robot <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
31343db0d3
commit
dfdffe1ac6
@@ -39,7 +39,6 @@ BList::BList(int32 blockSize)
|
|||||||
{
|
{
|
||||||
if (fBlockSize <= 0)
|
if (fBlockSize <= 0)
|
||||||
fBlockSize = 1;
|
fBlockSize = 1;
|
||||||
_ResizeArray(fItemCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -474,6 +473,9 @@ void BList::_ReservedList2() {}
|
|||||||
bool
|
bool
|
||||||
BList::_ResizeArray(int32 count)
|
BList::_ResizeArray(int32 count)
|
||||||
{
|
{
|
||||||
|
if (fPhysicalSize == count)
|
||||||
|
return true;
|
||||||
|
|
||||||
// calculate the new physical size
|
// calculate the new physical size
|
||||||
// by doubling the existing size
|
// by doubling the existing size
|
||||||
// until we can hold at least count items
|
// until we can hold at least count items
|
||||||
|
|||||||
Reference in New Issue
Block a user