mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
rustdoc: Avoid using Iterator::count()
where possible
`count()` iterates over the whole collection. Using `len()` instead, or `.next().is_none()` when comparing to zero, should be faster.
This commit is contained in:
parent
f4687d5381
commit
a792234388
@ -656,7 +656,7 @@ impl<'a, I> Footnotes<'a, I> {
|
||||
}
|
||||
|
||||
fn get_entry(&mut self, key: &str) -> &mut (Vec<Event<'a>>, u16) {
|
||||
let new_id = self.footnotes.keys().count() + 1;
|
||||
let new_id = self.footnotes.len() + 1;
|
||||
let key = key.to_owned();
|
||||
self.footnotes.entry(key).or_insert((Vec::new(), new_id as u16))
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ fn unindent_fragments(docs: &mut Vec<DocFragment>) {
|
||||
};
|
||||
|
||||
for fragment in docs {
|
||||
if fragment.doc.as_str().lines().count() == 0 {
|
||||
if fragment.doc.as_str().lines().next().is_none() {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user