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

Improve Array.Sort(T[]) performance #35297

Merged
merged 2 commits into from
Apr 24, 2020

Commits on Apr 24, 2020

  1. Improve Array.Sort(T[]) performance

    A variety of tweaks to improve `Array.Sort<T>(T[])` performance and address a regression left over from moving the array sorting implementation from native to managed.  The two most impactful are using `Unsafe.*` in `PickPivotAndPartition` to avoid bounds checks and aggressive inlining on `SwapIfGreater`.  A few other small improvements to codegen round it out.
    
    I only made the unsafe changes in the `Sort<T>(T[])` implementation, and not in the more complicated implementations, such as for `Sort<T>(T[], Comparer<T>)` and `Sort<TKey, TValue>(TKey[], TValue[])`, but I did make some of the smaller changes for consistency across the file.
    stephentoub committed Apr 24, 2020
    Configuration menu
    Copy the full SHA
    3ca4847 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2eef7dd View commit details
    Browse the repository at this point in the history