RecyclableList.SetNewLength fixed to properly initialize the list if the no. of memory blocks from array pool exceeds requested no.

This commit is contained in:
mlemanczyk committed 2023-03-26 23:22:32 +02:00
1 parent f231f7e0aa
commit c7052e778f
2 files changed
+4 -3

No files matched your search

+1 -1
View File
@@ -257,7 +257,7 @@ namespace Recyclable.Collections
}
localInts[uninitializedBlocksCount] = newMemoryBlocksSpan.Length;
if (localInts[uninitializedBlocksCount] == localInts[requiredBlockCount])
if (localInts[uninitializedBlocksCount] >= localInts[requiredBlockCount])
{
if (minBlockSize >= RecyclableDefaults.MinPooledArrayLength)
{
@@ -16,12 +16,13 @@ namespace Recyclable.CollectionsTests
public static readonly IEnumerable<long> ItemsCountVariants = new long[]
{
0, 1, 2, 3, 10, 16, 32, 64, 128, 256, 333, 512, 1_024, 8_192, 16_384
0, 1, 2, 3, 10, 16, 32, 64, 128, 256, 333, 512, 1_024, 8_192, 16_384,
1_000_000
};
public static readonly IEnumerable<int> BlockSizeVariants = new int[]
{
1, 2, 3, 10, 16, 32, 64, 128, 256, 512, 1_024, 2_048, 4_096,
1, 2, 4, 8, 10, 16, 32, 64, 128, 256, 512, 1_024, 2_048, 4_096,
8_192, 16_384
};