if converted to switch for performance improvements.
This commit is contained in:
1 parent
f45b6aac98
commit
43c2c6f13a
1 file changed
+15
-13
@@ -180,21 +180,23 @@ 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)
|
||||||
{
|
{
|
||||||
_memoryBlocks = SetNewLength(_memoryBlocks, blockSize, expectedItemsCount.Value);
|
case true:
|
||||||
if (_memoryBlocks.Length > 0)
|
_memoryBlocks = SetNewLength(_memoryBlocks, blockSize, expectedItemsCount.Value);
|
||||||
{
|
if (_memoryBlocks.Length > 0)
|
||||||
blockSize = _memoryBlocks[0].Length;
|
{
|
||||||
}
|
blockSize = _memoryBlocks[0].Length;
|
||||||
|
}
|
||||||
|
|
||||||
_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);
|
||||||
|
|||||||
Reference in new issue
Block a user