Unnecessary case removed.

This commit is contained in:
mlemanczyk committed 2023-01-29 14:07:34 +01:00
1 parent 604ee06697
commit 96f4912cd3
1 file changed
+9 -16
+9 -16
View File
@@ -83,28 +83,21 @@ namespace Recyclable.Collections
var sourceBlockCount = source?.Length ?? 0; var sourceBlockCount = source?.Length ?? 0;
int requiredBlockCount = (int)(newCapacity / blockSize) + (newCapacity % blockSize > 0 ? 1 : 0); int requiredBlockCount = (int)(newCapacity / blockSize) + (newCapacity % blockSize > 0 ? 1 : 0);
Span<T[]> sourceSpan, newArraySpan;
T[][] newMemoryBlocks = requiredBlockCount >= RecyclableDefaults.MinPooledArrayLength T[][] newMemoryBlocks = requiredBlockCount >= RecyclableDefaults.MinPooledArrayLength
? arrayPool.Rent(requiredBlockCount) ? arrayPool.Rent(requiredBlockCount)
: new T[requiredBlockCount][]; : new T[requiredBlockCount][];
switch (sourceBlockCount > 0) var newArraySpan = new Span<T[]>(newMemoryBlocks);
if (sourceBlockCount > 0)
{ {
case true: var sourceSpan = new Span<T[]>(source);
sourceSpan = new Span<T[]>(source); sourceSpan.CopyTo(newArraySpan);
newArraySpan = new Span<T[]>(newMemoryBlocks); if (sourceSpan.Length >= RecyclableDefaults.MinPooledArrayLength)
sourceSpan.CopyTo(newArraySpan); {
if (sourceSpan.Length >= RecyclableDefaults.MinPooledArrayLength) arrayPool.Return(source!);
{ }
arrayPool.Return(source!);
}
newArraySpan = newArraySpan[sourceBlockCount..]; newArraySpan = newArraySpan[sourceBlockCount..];
break;
case false:
newArraySpan = new Span<T[]>(newMemoryBlocks);
break;
} }
int uninitializedBlocksCount = newArraySpan.Length; int uninitializedBlocksCount = newArraySpan.Length;