RecyclableArrayList.AsArray() method converted to property for better performance.
This commit is contained in:
1 parent
3b73a2d877
commit
13fa23ac13
3 files changed
+4
-4
No files matched your search
+2
-2
@@ -498,7 +498,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
|||||||
targetBlockIndex = _nextItemBlockIndex,
|
targetBlockIndex = _nextItemBlockIndex,
|
||||||
memoryBlockCount = _memoryBlocks.Length;
|
memoryBlockCount = _memoryBlocks.Length;
|
||||||
|
|
||||||
Span<T> itemsSpan = new(items.AsArray(), 0, items.Count);
|
Span<T> itemsSpan = new(items.AsArray, 0, items.Count);
|
||||||
Span<T[]> memoryBlocksSpan = new(_memoryBlocks, 0, memoryBlockCount);
|
Span<T[]> memoryBlocksSpan = new(_memoryBlocks, 0, memoryBlockCount);
|
||||||
Span<T> targetBlockArraySpan = new(memoryBlocksSpan[targetBlockIndex], _nextItemIndex, blockSize - _nextItemIndex);
|
Span<T> targetBlockArraySpan = new(memoryBlocksSpan[targetBlockIndex], _nextItemIndex, blockSize - _nextItemIndex);
|
||||||
while (targetBlockArraySpan.Length <= itemsSpan.Length)
|
while (targetBlockArraySpan.Length <= itemsSpan.Length)
|
||||||
@@ -1397,7 +1397,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
|||||||
targetBlockIndex = _nextItemBlockIndex,
|
targetBlockIndex = _nextItemBlockIndex,
|
||||||
memoryBlockCount = _memoryBlocks.Length;
|
memoryBlockCount = _memoryBlocks.Length;
|
||||||
|
|
||||||
Span<T> itemsSpan = new(items.AsArray(), 0, items.Count);
|
Span<T> itemsSpan = new(items.AsArray, 0, items.Count);
|
||||||
Span<T[]> memoryBlocksSpan = new(_memoryBlocks, 0, memoryBlockCount);
|
Span<T[]> memoryBlocksSpan = new(_memoryBlocks, 0, memoryBlockCount);
|
||||||
Span<T> targetBlockArraySpan = new(memoryBlocksSpan[targetBlockIndex], _nextItemIndex, blockSize - _nextItemIndex);
|
Span<T> targetBlockArraySpan = new(memoryBlocksSpan[targetBlockIndex], _nextItemIndex, blockSize - _nextItemIndex);
|
||||||
while (targetBlockArraySpan.Length <= itemsSpan.Length)
|
while (targetBlockArraySpan.Length <= itemsSpan.Length)
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ namespace Recyclable.Collections
|
|||||||
_count = targetItemIdx;
|
_count = targetItemIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T[] AsArray() => _memoryBlock;
|
public T[] AsArray => _memoryBlock;
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -681,7 +681,7 @@ namespace Recyclable.Collections
|
|||||||
targetBlockIndex = _nextItemBlockIndex,
|
targetBlockIndex = _nextItemBlockIndex,
|
||||||
memoryBlockCount = _reservedBlockCount;
|
memoryBlockCount = _reservedBlockCount;
|
||||||
|
|
||||||
Span<T> itemsSpan = new(items.AsArray(), 0, items.Count);
|
Span<T> itemsSpan = new(items.AsArray, 0, items.Count);
|
||||||
Span<T[]> memoryBlocksSpan = new(_memoryBlocks, 0, memoryBlockCount);
|
Span<T[]> memoryBlocksSpan = new(_memoryBlocks, 0, memoryBlockCount);
|
||||||
Span<T> targetBlockArraySpan = new(memoryBlocksSpan[targetBlockIndex], _nextItemIndex, blockSize - _nextItemIndex);
|
Span<T> targetBlockArraySpan = new(memoryBlocksSpan[targetBlockIndex], _nextItemIndex, blockSize - _nextItemIndex);
|
||||||
while (targetBlockArraySpan.Length <= itemsSpan.Length)
|
while (targetBlockArraySpan.Length <= itemsSpan.Length)
|
||||||
|
|||||||
Reference in new issue
Block a user