Code readability - newArraySpan renamed => newMemoryBlocksSpan to match naming convention

This commit is contained in:
mlemanczyk committed 2023-01-29 14:13:31 +01:00
1 parent a9012dc25d
commit 16acdff58a
1 file changed
+10 -10
+10 -10
View File
@@ -86,36 +86,36 @@ namespace Recyclable.Collections
? arrayPool.Rent(requiredBlockCount) ? arrayPool.Rent(requiredBlockCount)
: new T[requiredBlockCount][]; : new T[requiredBlockCount][];
var newArraySpan = new Span<T[]>(newMemoryBlocks); var newMemoryBlocksSpan = new Span<T[]>(newMemoryBlocks);
if (sourceBlockCount > 0) if (sourceBlockCount > 0)
{ {
var sourceSpan = new Span<T[]>(source); var sourceSpan = new Span<T[]>(source);
sourceSpan.CopyTo(newArraySpan); sourceSpan.CopyTo(newMemoryBlocksSpan);
if (sourceSpan.Length >= RecyclableDefaults.MinPooledArrayLength) if (sourceSpan.Length >= RecyclableDefaults.MinPooledArrayLength)
{ {
arrayPool.Return(source!); arrayPool.Return(source!);
} }
newArraySpan = newArraySpan[sourceBlockCount..]; newMemoryBlocksSpan = newMemoryBlocksSpan[sourceBlockCount..];
} }
ArrayPool<T> blockArrayPool = _blockArrayPool; ArrayPool<T> blockArrayPool = _blockArrayPool;
int uninitializedBlocksCount = newArraySpan.Length; int uninitializedBlocksCount = newMemoryBlocksSpan.Length;
if (uninitializedBlocksCount == requiredBlockCount) if (uninitializedBlocksCount == requiredBlockCount)
{ {
switch (blockSize >= RecyclableDefaults.MinPooledArrayLength) switch (blockSize >= RecyclableDefaults.MinPooledArrayLength)
{ {
case true: case true:
newArraySpan[0] = blockArrayPool.Rent(blockSize); newMemoryBlocksSpan[0] = blockArrayPool.Rent(blockSize);
blockSize = newArraySpan[0].Length; blockSize = newMemoryBlocksSpan[0].Length;
break; break;
case false: case false:
newArraySpan[0] = new T[blockSize]; newMemoryBlocksSpan[0] = new T[blockSize];
break; break;
} }
newArraySpan = newArraySpan[1..]; newMemoryBlocksSpan = newMemoryBlocksSpan[1..];
uninitializedBlocksCount--; uninitializedBlocksCount--;
} }
@@ -124,7 +124,7 @@ namespace Recyclable.Collections
case true: case true:
for (int i = 0; i < uninitializedBlocksCount; i++) for (int i = 0; i < uninitializedBlocksCount; i++)
{ {
newArraySpan[i] = blockArrayPool.Rent(blockSize); newMemoryBlocksSpan[i] = blockArrayPool.Rent(blockSize);
} }
break; break;
@@ -132,7 +132,7 @@ namespace Recyclable.Collections
case false: case false:
for (int i = 0; i < uninitializedBlocksCount; i++) for (int i = 0; i < uninitializedBlocksCount; i++)
{ {
newArraySpan[i] = new T[blockSize]; newMemoryBlocksSpan[i] = new T[blockSize];
} }
break; break;