From 303fb689079f33011c952d7f7829f9a07124a8a8 Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Sun, 16 Jul 2023 11:55:54 +0200 Subject: [PATCH] RecyclableList.AddRangeEnumerated fixed to update _count before resizing the collection, because RecyclableListHelpers.ResizeAndCopy() relies on it. --- Recyclable.Collections/RecyclableList.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Recyclable.Collections/RecyclableList.cs b/Recyclable.Collections/RecyclableList.cs index 7647f61..3139163 100644 --- a/Recyclable.Collections/RecyclableList.cs +++ b/Recyclable.Collections/RecyclableList.cs @@ -36,6 +36,7 @@ namespace Recyclable.Collections { if (targetItemIndex + growByCount > capacity) { + _count = targetItemIndex; capacity = RecyclableListHelpers.ResizeAndCopy(this, checked((int)BitOperations.RoundUpToPowerOf2((uint)(targetItemIndex + growByCount)))); memorySpan = new(_memoryBlock); available = capacity - targetItemIndex;