about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-07-27 11:52:59 +0900
committerGitHub <noreply@github.com>2022-07-27 11:52:59 +0900
commit0d5bdcac5ff0c5cbc6ed0a04663788a23cc62adf (patch)
treec9b1ee24735430bef1867139c542ba426669742d
parentf8f07dece708e61cc18eb6806cfc5d1642e44e57 (diff)
parentb8fb6e103294f8a6028122df2650fff84f2e3e14 (diff)
Rollup merge of #99775 - notriddle:notriddle/as-str, r=camelid
rustdoc: do not allocate String when writing path full name

No idea if this makes any perf difference, but it just seems like premature pessimisation to use String when str will do.
-rw-r--r--src/librustdoc/clean/types.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs
index 2d364f3402e..83d8ed3fc87 100644
--- a/src/librustdoc/clean/types.rs
+++ b/src/librustdoc/clean/types.rs
@@ -2175,8 +2175,8 @@ impl Path {
     pub(crate) fn whole_name(&self) -> String {
         self.segments
             .iter()
-            .map(|s| if s.name == kw::PathRoot { String::new() } else { s.name.to_string() })
-            .intersperse("::".into())
+            .map(|s| if s.name == kw::PathRoot { "" } else { s.name.as_str() })
+            .intersperse("::")
             .collect()
     }