Skip to content

Commit ffc7a86

Browse files
committed
Directly index the underlying array in TransparentStack instead of indexing the RoSpan
1 parent 22f8546 commit ffc7a86

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Lib/Public/Util/ResizableBuffer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public class ResizableBuffer<T>
1616

1717
public ReadOnlyMemory<T> RoMemory => _buffer;
1818

19+
public ref readonly T this[int idx] => ref _buffer[idx];
20+
1921
public ResizableBuffer(int initialCapacity = 8)
2022
{
2123
_initialCapacity = initialCapacity;

src/Lib/Public/Util/TransparentStack.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ public void Clear()
2929

3030
public T Pop()
3131
{
32-
var item = _buffer.RoSpan[--_buffer.CurrentSize];
32+
var item = _buffer[--_buffer.CurrentSize];
3333
_buffer.Span[_buffer.CurrentSize] = default!;
3434
return item;
3535
}
3636

37-
public T Peek() => _buffer.RoSpan[_buffer.CurrentSize - 1];
37+
public T Peek() => _buffer[_buffer.CurrentSize - 1];
3838

39-
public T Peek(int offset) => _buffer.RoSpan[_buffer.CurrentSize - 1 - offset];
39+
public T Peek(int offset) => _buffer[_buffer.CurrentSize - 1 - offset];
4040
}

0 commit comments

Comments
 (0)