about summary refs log tree commit diff
path: root/src/librustdoc/clean
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2021-12-15 06:18:18 +1100
committerNoah Lev <camelidcamel@gmail.com>2022-01-14 11:57:18 -0800
commit10b1c9aa8b28f50cf7332960d1fc1e9b1d120eb7 (patch)
tree4dfb0c4e7ebdf28fcb2af9b0ed77fedf98572719 /src/librustdoc/clean
parent02c9e73e6ca7e2bd444d39182f8dee7e2ba4a609 (diff)
downloadrust-10b1c9aa8b28f50cf7332960d1fc1e9b1d120eb7.tar.gz
rust-10b1c9aa8b28f50cf7332960d1fc1e9b1d120eb7.zip
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.
Diffstat (limited to 'src/librustdoc/clean')
-rw-r--r--src/librustdoc/clean/inline.rs9
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!(