Tiny cleanup. Local var renamed to match other places.

This commit is contained in:
mlemanczyk committed 2023-07-16 11:52:45 +02:00
1 parent fc2335f5e4
commit 75ad8227c2
1 file changed
+7 -7
+7 -7
View File
@@ -21,7 +21,7 @@ namespace Recyclable.Collections
private IEnumerator<T> AddRangeEnumerated(IEnumerable<T> source, int growByCount) private IEnumerator<T> AddRangeEnumerated(IEnumerable<T> source, int growByCount)
{ {
int targetItemIdx = _count; int targetItemIndex = _count;
Span<T> memorySpan; Span<T> memorySpan;
int i; int i;
@@ -31,19 +31,19 @@ namespace Recyclable.Collections
memorySpan = new(_memoryBlock); memorySpan = new(_memoryBlock);
if (enumerator.MoveNext()) if (enumerator.MoveNext())
{ {
int available = capacity - targetItemIdx; int available = capacity - targetItemIndex;
do do
{ {
if (targetItemIdx + growByCount > capacity) if (targetItemIndex + growByCount > capacity)
{ {
capacity = RecyclableListHelpers<T>.ResizeAndCopy(this, checked((int)BitOperations.RoundUpToPowerOf2((uint)(capacity + growByCount)))); capacity = RecyclableListHelpers<T>.ResizeAndCopy(this, checked((int)BitOperations.RoundUpToPowerOf2((uint)(targetItemIndex + growByCount))));
memorySpan = new(_memoryBlock); memorySpan = new(_memoryBlock);
available = capacity - targetItemIdx; available = capacity - targetItemIndex;
} }
for (i = 0; i < available; i++) for (i = 0; i < available; i++)
{ {
memorySpan[targetItemIdx++] = enumerator.Current; memorySpan[targetItemIndex++] = enumerator.Current;
if (!enumerator.MoveNext()) if (!enumerator.MoveNext())
{ {
break; break;
@@ -54,7 +54,7 @@ namespace Recyclable.Collections
} }
_capacity = capacity; _capacity = capacity;
_count = targetItemIdx; _count = targetItemIndex;
return enumerator; return enumerator;
} }