diff options
| author | bors <bors@rust-lang.org> | 2022-01-14 20:34:18 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-01-14 20:34:18 +0000 |
| commit | b0ec3e09a996f2cb35be7710fd1003c3c38f1667 (patch) | |
| tree | d16992ea23c034bc46d776ef9aec8fd04172bfdc /src/librustdoc/clean | |
| parent | ad46af24713115e7b9b258346e66b9b2d14eacfc (diff) | |
| parent | c7147e4e1acd49ea01e6d67a85c270946554783a (diff) | |
| download | rust-b0ec3e09a996f2cb35be7710fd1003c3c38f1667.tar.gz rust-b0ec3e09a996f2cb35be7710fd1003c3c38f1667.zip | |
Auto merge of #91948 - nnethercote:rustdoc-more-Symbols, r=GuillaumeGomez
rustdoc: avoid many `Symbol` to `String` conversions. Particularly when constructing file paths and fully qualified paths. This avoids a lot of allocations, speeding things up on almost all examples. r? `@GuillaumeGomez`
Diffstat (limited to 'src/librustdoc/clean')
| -rw-r--r-- | src/librustdoc/clean/inline.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index b91ba5523e0..a2e612955b3 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -9,7 +9,6 @@ use rustc_data_structures::thin_vec::ThinVec; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; -use rustc_hir::definitions::DefPathData; use rustc_hir::Mutability; use rustc_metadata::creader::{CStore, LoadedMacro}; use rustc_middle::ty::{self, TyCtxt}; @@ -164,12 +163,10 @@ crate fn load_attrs<'hir>(cx: &DocContext<'hir>, did: DefId) -> Attrs<'hir> { /// These names are used later on by HTML rendering to generate things like /// source links back to the original item. crate fn record_extern_fqn(cx: &mut DocContext<'_>, did: DefId, kind: ItemType) { - let crate_name = cx.tcx.crate_name(did.krate).to_string(); + let crate_name = cx.tcx.crate_name(did.krate); - let relative = cx.tcx.def_path(did).data.into_iter().filter_map(|elem| { - // Filter out extern blocks - (elem.data != DefPathData::ForeignMod).then(|| elem.data.to_string()) - }); + let relative = + cx.tcx.def_path(did).data.into_iter().filter_map(|elem| elem.data.get_opt_name()); let fqn = if let ItemType::Macro = kind { // Check to see if it is a macro 2.0 or built-in macro if matches!( |
