From b8fb6e103294f8a6028122df2650fff84f2e3e14 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 26 Jul 2022 12:23:59 -0700 Subject: [PATCH] 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. --- src/librustdoc/clean/types.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 2d364f3402e96..83d8ed3fc87fb 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() }