Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #109399 - petrochenkov:rendersort, r=GuillaumeGomez
rustdoc: Optimize impl sorting during rendering This should fix the perf regression on [bitmaps-3.1.0](https://github.com/rust-lang/rustc-perf/tree/master/collector/compile-benchmarks/bitmaps-3.1.0) from rust-lang/rust#107765. The bitmaps crate has a lot of impls: ```rust impl Bits for BitsImpl<1> { ... } impl Bits for BitsImpl<2> { ... } // ... impl Bits for BitsImpl<1023> { ... } impl Bits for BitsImpl<1024> { ... } ``` and the logic in `fn print_item` sorts them in natural order. Before rust-lang/rust#107765 the impls came in source order, which happened to be already sorted in the necessary way. So the comparison function was called fewer times. After rust-lang/rust#107765 the impls came in "stable" order (based on def path hash). So the comparison function was called more times to sort them. The comparison function was terribly inefficient, so it caused a large perf regression. This PR attempts to make it more efficient by using cached keys during sorting.
- Loading branch information