Decoded on GetItem/SetItem performance. It's more stable & faster without them.
This commit is contained in:
1 parent
28b52c555d
commit
8147c4ecbf
1 file changed
+5
-18
@@ -47,28 +47,16 @@ namespace Recyclable.Collections
|
|||||||
|
|
||||||
public int BlockSize { get; }
|
public int BlockSize { get; }
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public static void SetItem(RecyclableBlockList<T[]> arrays, in int blockSize, in long index, in T value)
|
|
||||||
=> arrays[(int)(index / blockSize)][index % blockSize] = value;
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public static T GetItem(RecyclableBlockList<T[]> arrays, in int blockSize, in long index)
|
|
||||||
=> arrays[(int)(index / blockSize)][index % blockSize];
|
|
||||||
|
|
||||||
public T this[long index]
|
public T this[long index]
|
||||||
{
|
{
|
||||||
//get => GetItem(MemoryBlocks, BlockSize, index);
|
get => _memoryBlocks[(int)(index / _blockSize)][index % _blockSize];
|
||||||
//set => SetItem(MemoryBlocks, BlockSize, index, value);
|
set => _memoryBlocks[(int)(index / _blockSize)][index % _blockSize] = value;
|
||||||
get => _memoryBlocks[(int)(index / BlockSize)][index % BlockSize];
|
|
||||||
set => _memoryBlocks[(int)(index / BlockSize)][index % BlockSize] = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public T this[int index]
|
public T this[int index]
|
||||||
{
|
{
|
||||||
//get => GetItem(MemoryBlocks, BlockSize, index);
|
get => _memoryBlocks[index / _blockSize][index % _blockSize];
|
||||||
//set => SetItem(MemoryBlocks, BlockSize, index, value);
|
set => _memoryBlocks[index / _blockSize][index % _blockSize] = value;
|
||||||
get => _memoryBlocks[(int)(index / BlockSize)][index % BlockSize];
|
|
||||||
set => _memoryBlocks[(int)(index / BlockSize)][index % BlockSize] = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long Capacity { get; set; }
|
public long Capacity { get; set; }
|
||||||
@@ -87,8 +75,7 @@ namespace Recyclable.Collections
|
|||||||
Capacity += BlockSize;
|
Capacity += BlockSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetItem(_memoryBlocks, BlockSize, LongCount, item);
|
memoryBlocks[oldCount / blockSize][oldCount % blockSize] = item;
|
||||||
//_arrays[_arrays.LongCount - 1][LongCount % BlockSize] = item;
|
|
||||||
LongCount++;
|
LongCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user