From 2dc6d74b0b69003a52d49267dde7bd245569ec3a Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Tue, 31 Jan 2023 20:23:28 +0100 Subject: [PATCH] Fix to use the new _blockSize when we add capacity --- Recyclable.Collections/RecyclableList.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Recyclable.Collections/RecyclableList.cs b/Recyclable.Collections/RecyclableList.cs index f1b650b..2b6a58f 100644 --- a/Recyclable.Collections/RecyclableList.cs +++ b/Recyclable.Collections/RecyclableList.cs @@ -405,6 +405,9 @@ namespace Recyclable.Collections if (capacity < requiredCapacity) { _ = EnsureCapacity(requiredCapacity); + blockSize = _blockSize; + targetBlockIdx = (targetItemIdx / blockSize) + (targetItemIdx > 0 ? 1 : 0); + targetItemIdx = (int)(oldLongCount % blockSize); } memoryBlocksSpan = new(_memoryBlocks);