Commit e90149a
authored
Rollup merge of rust-lang#109616 - jsha:href-template, r=notriddle
rustdoc: use a template to generate Hrefs
Previously, href always returned a string, so each link incurred at least one allocation. We were also using `"../".repeat()`, and `.collect()` into strings to generate part of the paths. This abstracts away those repetitions into a couple of helper structs, ParentDirectories and PathComponents, and puts them together into an `Href` template, which should save some allocations. As a side benefit, I think it makes the logic of constructing links a little clearer.
This removes the only call sites for certain methods of UrlPartsBuilder, so it also removes those methods.
Also, remove the ItemType return value from `href` and friends; it was basically unused.
Part of rust-lang#108868File tree
7 files changed
+254
-214
lines changed- src/librustdoc
- clean
- html
- templates
- url_parts_builder
7 files changed
+254
-214
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
463 | | - | |
| 463 | + | |
| 464 | + | |
464 | 465 | | |
465 | 466 | | |
466 | 467 | | |
| |||
0 commit comments