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

Avoid boxing when structs are used as collection keys. #69443

Commits on Aug 9, 2023

  1. Avoid boxing when structs are used as collection keys.

    Change several structs to record structs such that they no longer are boxed when used as keys in MultiDictionary's internal ImmutableHashSet. When MultiDictionary's value is a struct and is created without specifying the value's IEqualityComparer, the default struct comparer is used. This equality comparer is notoriously slow due to boxing. By switching these structs to record structs, an implementation of IEquatable is generated and the default struct equality comparer isn't used.
    
    Addresses dotnet#69165
    
    Sam mentioned that there is an issue already logged in the roslyn-analyzers repo around adding an analyzer to detect this.
    
    dotnet/roslyn-analyzers#1640
    ToddGrun committed Aug 9, 2023
    Configuration menu
    Copy the full SHA
    6db1571 View commit details
    Browse the repository at this point in the history