Performance improvements
This commit is contained in:
1 parent
b9b4c40cf9
commit
35ccb12efc
1 file changed
+3
-4
@@ -179,14 +179,13 @@ namespace Recyclable.Collections
|
|||||||
|
|
||||||
protected long EnsureCapacity(in long requestedCapacity)
|
protected long EnsureCapacity(in long requestedCapacity)
|
||||||
{
|
{
|
||||||
long oldCapacity = _capacity;
|
|
||||||
T[][] memory = _memoryBlocks;
|
T[][] memory = _memoryBlocks;
|
||||||
long newCapacity;
|
long newCapacity;
|
||||||
|
|
||||||
switch (oldCapacity > 0)
|
switch (_capacity > 0)
|
||||||
{
|
{
|
||||||
case true:
|
case true:
|
||||||
newCapacity = oldCapacity;
|
newCapacity = _capacity;
|
||||||
while (newCapacity < requestedCapacity)
|
while (newCapacity < requestedCapacity)
|
||||||
{
|
{
|
||||||
newCapacity *= 2;
|
newCapacity *= 2;
|
||||||
@@ -200,7 +199,7 @@ namespace Recyclable.Collections
|
|||||||
}
|
}
|
||||||
|
|
||||||
memory = SetNewLength(memory, _blockSize, newCapacity);
|
memory = SetNewLength(memory, _blockSize, newCapacity);
|
||||||
if (oldCapacity == 0 && newCapacity > 0)
|
if (newCapacity > 0 && _capacity == 0)
|
||||||
{
|
{
|
||||||
_blockSize = memory[0].Length;
|
_blockSize = memory[0].Length;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user