From 8e2885ecd375320cd111f08f094bda615d6277be Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Sat, 9 Sep 2023 19:15:43 +0200 Subject: [PATCH] Failing tests fixed. RecyclableLongList.Insert(int) fixed. --- Recyclable.Collections/RecyclableLongList.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Recyclable.Collections/RecyclableLongList.cs b/Recyclable.Collections/RecyclableLongList.cs index 86affde..6f54dda 100644 --- a/Recyclable.Collections/RecyclableLongList.cs +++ b/Recyclable.Collections/RecyclableLongList.cs @@ -970,17 +970,19 @@ namespace Recyclable.Collections new Span(_memoryBlocks[_nextItemBlockIndex])[_nextItemIndex] = item; } - if (_nextItemIndex < _blockSizeMinus1) + if (++_nextItemIndex == _blockSize) { - if (++_nextItemIndex == 1) + if (_nextItemBlockIndex > _lastBlockWithData) { _lastBlockWithData++; } - } - else - { - _nextItemIndex = 0; + _nextItemBlockIndex++; + _nextItemIndex = 0; + } + else if (_nextItemIndex == 1 && _nextItemBlockIndex > _lastBlockWithData) + { + _lastBlockWithData++; } _version++;