Skip to content

Change most non-generic sorts to be generic #6285

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

Merged
merged 1 commit into from
Jul 21, 2022

Conversation

stephentoub
Copy link
Member

Description

Especially for the sorts based on int[], this avoids boxing potentially huge numbers of ints. Even for classes, it avoids unnecessary casting and expensive Array.Get/SetValue calls, and switching to a delegate avoids a top-level allocation for the comparer inside the current Array.Sort implementation.

Customer Impact

Unnecessary allocation, interface dispatch, expensive Array.Get/SetValue calls, etc.

Regression

No

Testing

CI

Risk

Minimal

@stephentoub stephentoub requested a review from a team as a code owner March 20, 2022 00:00
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Mar 20, 2022
@ghost ghost requested review from dipeshmsft, singhashish-wpf and SamBent March 20, 2022 00:00
Especially for the sorts based on int[], this avoids boxing potentially huge numbers of ints.  Even for classes, it avoids unnecessary casting, and switching to a delegate avoids a top-level allocation for the comparer inside the current Array.Sort implementation.
@singhashish-wpf singhashish-wpf merged commit b518cfb into dotnet:main Jul 21, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
PR metadata: Label to tag PRs, to facilitate with triage
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants