RecyclableList.Insert performance improvement. Local variable removed.
This commit is contained in:
1 parent
303fb68907
commit
e53d6a134c
1 file changed
+2
-4
@@ -293,7 +293,6 @@ namespace Recyclable.Collections
|
|||||||
|
|
||||||
int blockIndex,
|
int blockIndex,
|
||||||
sourceBlockSize = items.BlockSize,
|
sourceBlockSize = items.BlockSize,
|
||||||
// TODO: Convert to bit-shift
|
|
||||||
lastBlockIndex = (int)(sourceItemsCount >> items._blockSizePow2BitShift) - 1;
|
lastBlockIndex = (int)(sourceItemsCount >> items._blockSizePow2BitShift) - 1;
|
||||||
|
|
||||||
for (blockIndex = 0; blockIndex <= lastBlockIndex; blockIndex++)
|
for (blockIndex = 0; blockIndex <= lastBlockIndex; blockIndex++)
|
||||||
@@ -381,10 +380,9 @@ namespace Recyclable.Collections
|
|||||||
public void Insert(int index, T item)
|
public void Insert(int index, T item)
|
||||||
{
|
{
|
||||||
int oldCount = _count;
|
int oldCount = _count;
|
||||||
int requestedCapacity = oldCount + 1;
|
if (_capacity < oldCount + 1)
|
||||||
if (_capacity < requestedCapacity)
|
|
||||||
{
|
{
|
||||||
_capacity = RecyclableListHelpers<T>.ResizeAndCopy(this, checked((int)BitOperations.RoundUpToPowerOf2((uint)requestedCapacity)));
|
_capacity = RecyclableListHelpers<T>.ResizeAndCopy(this, checked((int)BitOperations.RoundUpToPowerOf2((uint)oldCount + 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldCount > 0)
|
if (oldCount > 0)
|
||||||
|
|||||||
Reference in new issue
Block a user