Performance improvement - removed unneeded case. We never hit it in our benchmarks or tests.

This commit is contained in:
mlemanczyk committed 2023-01-28 23:48:28 +01:00
1 parent 06ef3d4fa4
commit 8b7c4407d5
1 file changed
-25
-25
View File
@@ -88,9 +88,6 @@ namespace Recyclable.Collections
? arrayPool.Rent(requiredBlockCount) ? arrayPool.Rent(requiredBlockCount)
: new T[requiredBlockCount][]; : new T[requiredBlockCount][];
switch (requiredBlockCount >= sourceBlockCount)
{
case true:
switch (sourceBlockCount > 0) switch (sourceBlockCount > 0)
{ {
case true: case true:
@@ -149,28 +146,6 @@ namespace Recyclable.Collections
} }
return newMemoryBlocks; return newMemoryBlocks;
case false:
sourceSpan = new Span<T[]>(source)[..requiredBlockCount];
newArraySpan = new Span<T[]>(newMemoryBlocks);
sourceSpan.CopyTo(newArraySpan);
sourceSpan = new Span<T[]>(source)[newArraySpan.Length..];
int sourceLength = sourceSpan.Length;
if (blockSize >= RecyclableDefaults.MinPooledArrayLength)
{
for (int i = 0; i < sourceLength; i++)
{
blockArrayPool.Return(sourceSpan[i]);
}
}
if (sourceLength >= RecyclableDefaults.MinPooledArrayLength)
{
arrayPool.Return(source!);
}
return newMemoryBlocks;
}
} }
protected long EnsureCapacity(in long requestedCapacity) protected long EnsureCapacity(in long requestedCapacity)