Skip to content

Commit b8fb6e1

Browse files
committed
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.
1 parent c9b3183 commit b8fb6e1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/librustdoc/clean/types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2175,8 +2175,8 @@ impl Path {
21752175
pub(crate) fn whole_name(&self) -> String {
21762176
self.segments
21772177
.iter()
2178-
.map(|s| if s.name == kw::PathRoot { String::new() } else { s.name.to_string() })
2179-
.intersperse("::".into())
2178+
.map(|s| if s.name == kw::PathRoot { "" } else { s.name.as_str() })
2179+
.intersperse("::")
21802180
.collect()
21812181
}
21822182

0 commit comments

Comments
 (0)