From 9b9b68346247903a78f1422643fd629ff86dd4c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Lema=C5=84czyk?= Date: Sat, 11 Mar 2023 22:09:36 +0100 Subject: [PATCH] RecyclableList.AddRange(RecyclableList items) fixed to copy items only within block size & skip the rest. --- Recyclable.Collections/RecyclableList.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Recyclable.Collections/RecyclableList.cs b/Recyclable.Collections/RecyclableList.cs index 3c8c682..754b83e 100644 --- a/Recyclable.Collections/RecyclableList.cs +++ b/Recyclable.Collections/RecyclableList.cs @@ -388,7 +388,7 @@ namespace Recyclable.Collections if (targetBlockArraySpan.IsEmpty && copiedCount < itemsCount) { targetBlockIndex++; - targetBlockArraySpan = new(targetMemoryBlocksSpan[targetBlockIndex]); + targetBlockArraySpan = new(targetMemoryBlocksSpan[targetBlockIndex], 0, blockSize); } } } @@ -532,7 +532,6 @@ namespace Recyclable.Collections Span blockArraySpan; if (source.TryGetNonEnumeratedCount(out var requiredAdditionalCapacity)) { - int requiredCapacity = targetItemIdx + requiredAdditionalCapacity; if (capacity < requiredCapacity) {