From 10189d0d118915846e2ed9de1b16c1e88645acd1 Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Sun, 16 Jul 2023 12:14:13 +0200 Subject: [PATCH] RecyclableLongList.AddRangeWithKnownCount fixed for cases when both collections are empty. --- Recyclable.Collections/RecyclableLongList.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Recyclable.Collections/RecyclableLongList.cs b/Recyclable.Collections/RecyclableLongList.cs index 6155546..0087e71 100644 --- a/Recyclable.Collections/RecyclableLongList.cs +++ b/Recyclable.Collections/RecyclableLongList.cs @@ -146,6 +146,11 @@ namespace Recyclable.Collections Span memoryBlocksSpan; Span blockArraySpan; long requiredCapacity = copied + requiredAdditionalCapacity; + if (requiredCapacity == 0) + { + return; + } + if (_capacity < requiredCapacity) { _capacity = Helpers.Resize(this, _blockSize, _blockSizePow2BitShift, checked((long)BitOperations.RoundUpToPowerOf2((ulong)requiredCapacity)));