Skip to content

Change most non-generic sorts to be generic#6285

Merged
singhashish-wpf merged 1 commit intodotnet:mainfrom
stephentoub:genericsort
Jul 21, 2022
Merged

Change most non-generic sorts to be generic#6285
singhashish-wpf merged 1 commit intodotnet:mainfrom
stephentoub:genericsort

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 SamBent, dipeshmsft and singhashish-wpf 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