if converted to switch for performance improvements.

This commit is contained in:
mlemanczyk committed 2023-01-23 01:40:11 +01:00
1 parent f45b6aac98
commit 43c2c6f13a
1 file changed
+6 -4
+6 -4
View File
@@ -180,8 +180,9 @@ namespace Recyclable.Collections
public RecyclableList(IEnumerable<T> source, int blockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default) public RecyclableList(IEnumerable<T> source, int blockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default)
{ {
if (expectedItemsCount > 0) switch (expectedItemsCount > 0)
{ {
case true:
_memoryBlocks = SetNewLength(_memoryBlocks, blockSize, expectedItemsCount.Value); _memoryBlocks = SetNewLength(_memoryBlocks, blockSize, expectedItemsCount.Value);
if (_memoryBlocks.Length > 0) if (_memoryBlocks.Length > 0)
{ {
@@ -190,11 +191,12 @@ namespace Recyclable.Collections
_blockSize = blockSize; _blockSize = blockSize;
_capacity = _memoryBlocks.Length * blockSize; _capacity = _memoryBlocks.Length * blockSize;
} break;
else
{ case false:
_blockSize = blockSize; _blockSize = blockSize;
_memoryBlocks = _emptyBlockArray; _memoryBlocks = _emptyBlockArray;
break;
} }
AddRange(source); AddRange(source);