Tiny cleanup

This commit is contained in:
mlemanczyk committed 2023-04-12 23:57:17 +02:00
1 parent ef09143eb1
commit 22060c4390
1 file changed
+17 -17
+17 -17
View File
@@ -330,6 +330,23 @@ namespace Recyclable.Collections
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)]
public static long EnsureCapacity(RecyclableList<T> list, long requestedCapacity)
{
@@ -349,23 +366,6 @@ namespace Recyclable.Collections
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)]
#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)