Tiny cleanup
This commit is contained in:
1 parent
ef09143eb1
commit
22060c4390
1 file changed
+17
-17
@@ -330,6 +330,23 @@ namespace Recyclable.Collections
|
|||||||
return (long)newMemoryBlocks.Length << minBlockSizePow2Shift;
|
return (long)newMemoryBlocks.Length << minBlockSizePow2Shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
|
protected static void SetupBlockArrayPooling(RecyclableList<T> list, int blockSize, ArrayPool<T>? blockArrayPool = null)
|
||||||
|
{
|
||||||
|
list._blockSize = blockSize;
|
||||||
|
list._blockSizePow2Shift = (byte)(31 - BitOperations.LeadingZeroCount((uint)blockSize));
|
||||||
|
if (blockSize >= RecyclableDefaults.MinPooledArrayLength)
|
||||||
|
{
|
||||||
|
list._blockPoolingRequired = true;
|
||||||
|
list._blockArrayPool = blockArrayPool ?? RecyclableArrayPool<T>.Shared(blockSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list._blockPoolingRequired = false;
|
||||||
|
list._blockArrayPool = RecyclableArrayPool<T>.Null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
public static long EnsureCapacity(RecyclableList<T> list, long requestedCapacity)
|
public static long EnsureCapacity(RecyclableList<T> list, long requestedCapacity)
|
||||||
{
|
{
|
||||||
@@ -349,23 +366,6 @@ namespace Recyclable.Collections
|
|||||||
return newCapacity;
|
return newCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
protected static void SetupBlockArrayPooling(RecyclableList<T> list, int blockSize, ArrayPool<T>? blockArrayPool = null)
|
|
||||||
{
|
|
||||||
list._blockSize = blockSize;
|
|
||||||
list._blockSizePow2Shift = (byte)(31 - BitOperations.LeadingZeroCount((uint)blockSize));
|
|
||||||
if (blockSize >= RecyclableDefaults.MinPooledArrayLength)
|
|
||||||
{
|
|
||||||
list._blockPoolingRequired = true;
|
|
||||||
list._blockArrayPool = blockArrayPool ?? RecyclableArrayPool<T>.Shared(blockSize);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
list._blockPoolingRequired = false;
|
|
||||||
list._blockArrayPool = RecyclableArrayPool<T>.Null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||||
#pragma warning disable CS8618 // It's set by SetupBlockArrayPooling
|
#pragma warning disable CS8618 // It's set by SetupBlockArrayPooling
|
||||||
public RecyclableList(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
public RecyclableList(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||||
|
|||||||
Reference in new issue
Block a user