Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make randomized string equality comparers implement IAlternateEqualityComparer #104252

Merged
merged 2 commits into from
Jul 2, 2024

Conversation

stephentoub
Copy link
Member

When Dictionary<string,TValue> and HashSet<string> upgrade from a non-randomized comparer to a randomized comparer, they don't just switch to using StringComparer.Xx... for an extra layer of protection, they create a dedicated comparer with its own random seed rather than sharing the global one. This is accomplished with a couple of dedicated comparer types. When I added IAlternateEqualityComparer implementations to all the things, I missed these two cases. That means when if a dictionary/hashset experienced enough collisions to upgrade, it could lose its ability to perform alternate key lookups. This PR just fixes those two stragglers.

(This will not pass CI until #104202 is merged, as the tests here expect that the default comparer supports alternates.)

Copy link
Contributor

@IDisposable IDisposable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants