RecyclableLongList.Remove & .RemoveAt fixed to correctly set _lastBlockWithData to -1, when we remove the last item.

This commit is contained in:
mlemanczyk committed 2023-08-05 19:18:13 +02:00
1 parent 268dbb5b1d
commit 5a2ae1c261
1 file changed
+18 -12
+18 -12
View File
@@ -921,10 +921,7 @@ namespace Recyclable.Collections
if (_nextItemIndex > 0) if (_nextItemIndex > 0)
{ {
if (--_nextItemIndex == 0) _nextItemIndex--;
{
_lastBlockWithData--;
}
} }
else else
{ {
@@ -932,6 +929,11 @@ namespace Recyclable.Collections
_nextItemBlockIndex--; _nextItemBlockIndex--;
} }
if (_nextItemIndex == 0)
{
_lastBlockWithData--;
}
if (NeedsClearing) if (NeedsClearing)
{ {
#nullable disable #nullable disable
@@ -987,10 +989,7 @@ namespace Recyclable.Collections
if (_nextItemIndex > 0) if (_nextItemIndex > 0)
{ {
if (--_nextItemIndex == 0) _nextItemIndex--;
{
_lastBlockWithData--;
}
} }
else else
{ {
@@ -998,6 +997,11 @@ namespace Recyclable.Collections
_nextItemBlockIndex--; _nextItemBlockIndex--;
} }
if (_nextItemIndex == 0)
{
_lastBlockWithData--;
}
if (NeedsClearing) if (NeedsClearing)
{ {
#nullable disable #nullable disable
@@ -1023,10 +1027,7 @@ namespace Recyclable.Collections
if (_nextItemIndex > 0) if (_nextItemIndex > 0)
{ {
if (--_nextItemIndex == 0) _nextItemIndex--;
{
_lastBlockWithData--;
}
} }
else else
{ {
@@ -1034,6 +1035,11 @@ namespace Recyclable.Collections
_nextItemBlockIndex--; _nextItemBlockIndex--;
} }
if (_nextItemIndex == 0)
{
_lastBlockWithData--;
}
if (NeedsClearing) if (NeedsClearing)
{ {
#nullable disable #nullable disable