RecyclableLongList.Enumerator restored as the issue was somewhere else.

This commit is contained in:
mlemanczyk committed 2023-09-10 12:28:29 +02:00
1 parent 8e2885ecd3
commit 9cd2096783
1 file changed
+8 -1
@@ -26,7 +26,7 @@ namespace Recyclable.Collections
{
var list = _list;
if (_currentBlockIndex <= list._lastBlockWithData && _currentItemIndex <= (_currentBlockIndex == list._lastBlockWithData && list._nextItemIndex > 0 ? list._nextItemIndex - 1: list._blockSizeMinus1))
if (_currentBlockIndex < list._lastBlockWithData)
{
_current = list._memoryBlocks[_currentBlockIndex][_currentItemIndex];
if (_currentItemIndex + 1 < list._blockSize)
@@ -41,7 +41,14 @@ namespace Recyclable.Collections
return true;
}
// Move to the next item if we're within block boundaries, otherwise report end of collection.
if (list._longCount > 0 && _currentItemIndex < (list._nextItemIndex > 0 ? list._nextItemIndex : list._blockSize))
{
_current = list._memoryBlocks[_currentBlockIndex][_currentItemIndex];
_currentItemIndex++;
return true;
}
return false;
}