RecyclableList.LastTakenBlockIndex renamed to LastBlockWithData. Tiny cleanup.
This commit is contained in:
1 parent
2d7e62df72
commit
abbd568c6b
2 files changed
+9
-9
No files matched your search
@@ -110,7 +110,7 @@ namespace Recyclable.Collections.Benchmarks
|
|||||||
int blockSize = data.BlockSize;
|
int blockSize = data.BlockSize;
|
||||||
int nextItemBlockIndex = data.NextItemBlockIndex;
|
int nextItemBlockIndex = data.NextItemBlockIndex;
|
||||||
|
|
||||||
var memoryBlocks = new Span<object[]>(data.MemoryBlocks, 0, data.LastTakenBlockIndex + 1);
|
var memoryBlocks = new Span<object[]>(data.MemoryBlocks, 0, data.LastBlockWithData + 1);
|
||||||
for (var blockIndex = 0; blockIndex < nextItemBlockIndex; blockIndex++)
|
for (var blockIndex = 0; blockIndex < nextItemBlockIndex; blockIndex++)
|
||||||
{
|
{
|
||||||
var memoryBlock = new Span<object>(memoryBlocks[blockIndex], 0, blockSize);
|
var memoryBlock = new Span<object>(memoryBlocks[blockIndex], 0, blockSize);
|
||||||
@@ -120,7 +120,7 @@ namespace Recyclable.Collections.Benchmarks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextItemBlockIndex == data.LastTakenBlockIndex)
|
if (nextItemBlockIndex == data.LastBlockWithData)
|
||||||
{
|
{
|
||||||
|
|
||||||
var memoryBlock = new Span<object>(memoryBlocks[nextItemBlockIndex], 0, data.NextItemIndex);
|
var memoryBlock = new Span<object>(memoryBlocks[nextItemBlockIndex], 0, data.NextItemIndex);
|
||||||
@@ -149,7 +149,7 @@ namespace Recyclable.Collections.Benchmarks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextItemBlockIndex == data.LastTakenBlockIndex)
|
if (nextItemBlockIndex == data.LastBlockWithData)
|
||||||
{
|
{
|
||||||
var memoryBlock = memoryBlocks[nextItemBlockIndex];
|
var memoryBlock = memoryBlocks[nextItemBlockIndex];
|
||||||
blockSize = data.NextItemIndex;
|
blockSize = data.NextItemIndex;
|
||||||
@@ -203,7 +203,7 @@ namespace Recyclable.Collections.Benchmarks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextItemBlockIndex == data.LastTakenBlockIndex)
|
if (nextItemBlockIndex == data.LastBlockWithData)
|
||||||
{
|
{
|
||||||
memoryBlock = memoryBlocks[nextItemBlockIndex];
|
memoryBlock = memoryBlocks[nextItemBlockIndex];
|
||||||
blockSize = data.NextItemIndex;
|
blockSize = data.NextItemIndex;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace Recyclable.Collections
|
|||||||
|
|
||||||
public int Count => checked((int)_longCount);
|
public int Count => checked((int)_longCount);
|
||||||
public bool IsReadOnly { get; }
|
public bool IsReadOnly { get; }
|
||||||
public int LastTakenBlockIndex => _nextItemBlockIndex - (_nextItemIndex > 0 ? 0 : 1);
|
public int LastBlockWithData => _nextItemBlockIndex - (_nextItemIndex > 0 ? 0 : 1);
|
||||||
|
|
||||||
protected long _longCount;
|
protected long _longCount;
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ namespace Recyclable.Collections
|
|||||||
int targetBlockIndex = checked((int)(index >> list._blockSizePow2Shift));
|
int targetBlockIndex = checked((int)(index >> list._blockSizePow2Shift));
|
||||||
int targetItemIndex = checked((int)(index & (blockSize - 1)));
|
int targetItemIndex = checked((int)(index & (blockSize - 1)));
|
||||||
|
|
||||||
int lastTakenBlockIndex = list.LastTakenBlockIndex;
|
int lastTakenBlockIndex = list.LastBlockWithData;
|
||||||
while (sourceBlockIndex < lastTakenBlockIndex || (sourceBlockIndex == lastTakenBlockIndex && (sourceItemIndex < nextItemIndex || sourceBlockIndex != list._nextItemBlockIndex)))
|
while (sourceBlockIndex < lastTakenBlockIndex || (sourceBlockIndex == lastTakenBlockIndex && (sourceItemIndex < nextItemIndex || sourceBlockIndex != list._nextItemBlockIndex)))
|
||||||
{
|
{
|
||||||
int toCopy = sourceBlockIndex < lastTakenBlockIndex || nextItemIndex == 0
|
int toCopy = sourceBlockIndex < lastTakenBlockIndex || nextItemIndex == 0
|
||||||
@@ -334,7 +334,7 @@ namespace Recyclable.Collections
|
|||||||
: requestedCapacity;
|
: requestedCapacity;
|
||||||
|
|
||||||
int blockSize = list._blockSize;
|
int blockSize = list._blockSize;
|
||||||
newCapacity = RecyclableList<T>.Resize(list, blockSize, list._blockSizePow2Shift, newCapacity);
|
newCapacity = Resize(list, blockSize, list._blockSizePow2Shift, newCapacity);
|
||||||
if (newCapacity > 0 && blockSize != list._memoryBlocks[0].Length)
|
if (newCapacity > 0 && blockSize != list._memoryBlocks[0].Length)
|
||||||
{
|
{
|
||||||
blockSize = list._memoryBlocks[0].Length;
|
blockSize = list._memoryBlocks[0].Length;
|
||||||
@@ -814,7 +814,7 @@ namespace Recyclable.Collections
|
|||||||
? ItemNotFoundIndex
|
? ItemNotFoundIndex
|
||||||
: _nextItemBlockIndex == 0 || (_nextItemBlockIndex == 1 && _nextItemIndex == 0)
|
: _nextItemBlockIndex == 0 || (_nextItemBlockIndex == 1 && _nextItemIndex == 0)
|
||||||
? Array.IndexOf(_memoryBlocks[0], item, 0, checked((int)_longCount))
|
? Array.IndexOf(_memoryBlocks[0], item, 0, checked((int)_longCount))
|
||||||
: checked((int)DoIndexOf(item, _memoryBlocks, LastTakenBlockIndex, _blockSize, _nextItemIndex));
|
: checked((int)DoIndexOf(item, _memoryBlocks, LastBlockWithData, _blockSize, _nextItemIndex));
|
||||||
|
|
||||||
public void Insert(int index, T item) => throw new NotSupportedException();
|
public void Insert(int index, T item) => throw new NotSupportedException();
|
||||||
|
|
||||||
@@ -823,7 +823,7 @@ namespace Recyclable.Collections
|
|||||||
? ItemNotFoundIndex
|
? ItemNotFoundIndex
|
||||||
: _nextItemBlockIndex == 0 || (_nextItemBlockIndex == 1 && _nextItemIndex == 0)
|
: _nextItemBlockIndex == 0 || (_nextItemBlockIndex == 1 && _nextItemIndex == 0)
|
||||||
? Array.IndexOf(_memoryBlocks[0], item, 0, checked((int)_longCount))
|
? Array.IndexOf(_memoryBlocks[0], item, 0, checked((int)_longCount))
|
||||||
: DoIndexOf(item, _memoryBlocks, LastTakenBlockIndex, _blockSize, _nextItemIndex);
|
: DoIndexOf(item, _memoryBlocks, LastBlockWithData, _blockSize, _nextItemIndex);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
public bool Remove(T item)
|
public bool Remove(T item)
|
||||||
|
|||||||
Reference in new issue
Block a user