RecyclableLongList.Enumerator & .VersionedEnumerator will clear the current value only when it's reference type. Tiny cleanup.
This commit is contained in:
1 parent
55dd7ba078
commit
8352575043
2 files changed
+10
-6
No files matched your search
@@ -11,8 +11,6 @@ namespace Recyclable.Collections
|
|||||||
private static readonly T _default = default;
|
private static readonly T _default = default;
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|
||||||
private static readonly bool _isReferenceType = !typeof(T).IsValueType;
|
|
||||||
|
|
||||||
private int _currentBlockIndex;
|
private int _currentBlockIndex;
|
||||||
private int _currentItemIndex;
|
private int _currentItemIndex;
|
||||||
private readonly RecyclableLongList<T> _list;
|
private readonly RecyclableLongList<T> _list;
|
||||||
@@ -68,15 +66,19 @@ namespace Recyclable.Collections
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
|
{
|
||||||
|
if (NeedsClearing)
|
||||||
{
|
{
|
||||||
_current = _default;
|
_current = _default;
|
||||||
|
}
|
||||||
|
|
||||||
_currentBlockIndex = 0;
|
_currentBlockIndex = 0;
|
||||||
_currentItemIndex = 0;
|
_currentItemIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (_isReferenceType)
|
if (NeedsClearing)
|
||||||
{
|
{
|
||||||
_current = _default;
|
_current = _default;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ namespace Recyclable.Collections
|
|||||||
private static readonly T _default = default;
|
private static readonly T _default = default;
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|
||||||
private static readonly bool _isReferenceType = !typeof(T).IsValueType;
|
|
||||||
|
|
||||||
private int _currentBlockIndex;
|
private int _currentBlockIndex;
|
||||||
private int _currentItemIndex;
|
private int _currentItemIndex;
|
||||||
private readonly RecyclableLongList<T> _list;
|
private readonly RecyclableLongList<T> _list;
|
||||||
@@ -88,14 +86,18 @@ namespace Recyclable.Collections
|
|||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NeedsClearing)
|
||||||
|
{
|
||||||
_current = _default;
|
_current = _default;
|
||||||
|
}
|
||||||
|
|
||||||
_currentBlockIndex = 0;
|
_currentBlockIndex = 0;
|
||||||
_currentItemIndex = 0;
|
_currentItemIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (_isReferenceType)
|
if (NeedsClearing)
|
||||||
{
|
{
|
||||||
_current = _default;
|
_current = _default;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user