Small performance improvements to avoid repeated clearing of the buffers.

This commit is contained in:
mlemanczyk committed 2023-06-25 23:58:46 +02:00
1 parent 6b3b30fc12
commit 4f7af026f7
2 files changed
+4 -2

No files matched your search

+2 -1
View File
@@ -535,7 +535,8 @@ namespace Recyclable.Collections
Clear();
if (_count is >= RecyclableDefaults.MinPooledArrayLength)
{
_arrayPool.Return(_memoryBlock, NeedsClearing);
// If anything, it has been already cleared by .Clear(), Remove() or RemoveAt() methods, as the list was modified / disposed.
_arrayPool.Return(_memoryBlock, false);
}
}
+2 -1
View File
@@ -1302,7 +1302,8 @@ namespace Recyclable.Collections
Clear();
if (_memoryBlocks.Length >= RecyclableDefaults.MinPooledArrayLength)
{
_memoryBlocksPool.Return(_memoryBlocks, NeedsClearing);
// If anything, it has been already cleared by .Clear(), Remove() or RemoveAt() methods, as the list was modified / disposed.
_memoryBlocksPool.Return(_memoryBlocks, false);
}
}