Skip to content

Commit 19b0648

Browse files
authored
Fix perf. regression caused by signed/unsigned comp (#79137)
1 parent e395c7c commit 19b0648

File tree

1 file changed

+2
-2
lines changed
  • src/libraries/System.Private.CoreLib/src/System/Collections/Generic

1 file changed

+2
-2
lines changed

src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Queue.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ public bool MoveNext()
453453

454454
// Cache some fields in locals to decrease code size
455455
T[] array = _q._array;
456-
int capacity = array.Length;
456+
uint capacity = (uint)array.Length;
457457

458458
// _index represents the 0-based index into the queue, however the queue
459459
// doesn't have to start from 0 and it may not even be stored contiguously in memory.
@@ -467,7 +467,7 @@ public bool MoveNext()
467467
// Replacing it with simple comparison/subtraction operations sped up
468468
// the average foreach loop by 2x.
469469

470-
arrayIndex -= (uint)capacity; // wrap around if needed
470+
arrayIndex -= capacity; // wrap around if needed
471471
}
472472

473473
_currentElement = array[arrayIndex];

0 commit comments

Comments
 (0)