Files
rust/tests/rustdoc-html/deref
Jonathan Brouwer b255ecd171 Rollup merge of #162976 - xonx4l:rustdoc-sidebar-quadratic, r=lolbinarycat,GuillaumeGomez
fix quadratic naming of duplicate sidebar links

This PR fixes quadratic naming of duplicate sidebar links as discussed in https://github.com/rust-lang/rust/issues/158174.

Fixes rust-lang/rust#158174

`get_next_url` gives duplicate sidebar links with unique names but it started counting from 1 every time which makes the page quadratic.

So to make it more optimal I changed that to remember the next  unique number for each name  making it linear per page.

Also added the test at `tests/rustdoc-html/deref/sidebar-links-deref-chain.rs`

### Results

| N    | Instructions (before) | Instructions (after) | Time (before) | Time (after) |
|-----:|----------------------:|---------------------:|--------------:|-------------:|
| 200  | 5.71 B                | 3.69 B               | 1.20 s        | 1.01 s       |
| 400  | 22.40 B               | 9.52 B               | 3.79 s        | 1.98 s       |
| 800  | 126.83 B              | 30.82 B              | 19.68 s       | 6.04 s       |
| 1600 | —                     | —                    | 118.59 s      | 37.76 s      |

r? @GuillaumeGomez
2026-09-24 09:38:09 +02:00
..