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

Commit

Permalink
Drop range check
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams committed Dec 15, 2017
1 parent 40fc408 commit 2ea4ec2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/mscorlib/shared/System/Collections/Generic/Dictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,18 @@ private int FindEntry(TKey key)
i = buckets[hashCode % buckets.Length];

Entry[] entries = _entries;
while (i >= 0)
do
{
if (entries[i].hashCode == hashCode && comparer.Equals(entries[i].key, key))
// Should be a while loop https://github.com/dotnet/coreclr/issues/15476
// Test in if to drop range check for following array access
if ((uint)i >= (uint)entries.Length || (entries[i].hashCode == hashCode && comparer.Equals(entries[i].key, key)))
{
break;
}

i = entries[i].next;
}
} while (true);
}
return i;
}
Expand Down

0 comments on commit 2ea4ec2

Please sign in to comment.