Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit b0bfd83

Browse files
committed
Array-copy in Peek is not necessary, JIT can do the same
As of PR-feedback #26086 (comment)
1 parent f337882 commit b0bfd83

File tree

1 file changed

+2
-3
lines changed
  • src/System.Collections/src/System/Collections/Generic

1 file changed

+2
-3
lines changed

src/System.Collections/src/System/Collections/Generic/Stack.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,13 @@ public void TrimExcess()
203203
public T Peek()
204204
{
205205
int size = _size - 1;
206-
T[] array = _array;
207206

208-
if ((uint)size >= (uint)array.Length)
207+
if ((uint)size >= (uint)_array.Length)
209208
{
210209
ThrowForEmptyStack();
211210
}
212211

213-
return array[size];
212+
return _array[size];
214213
}
215214

216215
public bool TryPeek(out T result)

0 commit comments

Comments
 (0)