Skip to content

Commit bf7d7ae

Browse files
blussestebank
authored andcommitted
use &str instead of String
1 parent 08aa825 commit bf7d7ae

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/librustdoc/clean/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2205,8 +2205,8 @@ impl Path {
22052205
}
22062206
}
22072207

2208-
pub fn last_name(&self) -> String {
2209-
self.segments.last().unwrap().name.clone()
2208+
pub fn last_name(&self) -> &str {
2209+
self.segments.last().unwrap().name
22102210
}
22112211
}
22122212

src/librustdoc/html/render.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -2110,23 +2110,22 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
21102110
<h2 id='implementors'>Implementors</h2>
21112111
<ul class='item-list' id='implementors-list'>
21122112
")?;
2113-
let mut implementor_count: FxHashMap<String, usize> = FxHashMap();
2114-
for (_, implementors) in cache.implementors.iter() {
2113+
if let Some(implementors) = cache.implementors.get(&it.def_id) {
2114+
let mut implementor_count: FxHashMap<&str, usize> = FxHashMap();
21152115
for implementor in implementors {
21162116
if let clean::Type::ResolvedPath {ref path, ..} = implementor.impl_.for_ {
21172117
*implementor_count.entry(path.last_name()).or_insert(0) += 1;
21182118
}
21192119
}
2120-
}
2121-
if let Some(implementors) = cache.implementors.get(&it.def_id) {
2122-
for implementor in implementors.iter() {
2120+
2121+
for implementor in implementors {
21232122
write!(w, "<li><code>")?;
21242123
// If there's already another implementor that has the same abbridged name, use the
21252124
// full path, for example in `std::iter::ExactSizeIterator`
21262125
let dissambiguate = if let clean::Type::ResolvedPath {
21272126
ref path, ..
21282127
} = implementor.impl_.for_ {
2129-
*implementor_count.get(&path.last_name()).unwrap_or(&0) > 1
2128+
implementor_count[path.last_name()] > 1
21302129
} else {
21312130
false
21322131
};

0 commit comments

Comments
 (0)