Skip to content

Commit 480eb77

Browse files
committed
avoid intermediately collecting into vectors
1 parent 6db4fc9 commit 480eb77

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/librustdoc/html/render/write_shared.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ impl TraitAliasPart {
733733
},
734734
};
735735

736-
let implementors = imps
736+
let mut implementors = imps
737737
.iter()
738738
.filter_map(|imp| {
739739
// If the trait and implementation are in the same crate, then
@@ -755,12 +755,12 @@ impl TraitAliasPart {
755755
})
756756
}
757757
})
758-
.collect::<Vec<_>>();
758+
.peekable();
759759

760760
// Only create a js file if we have impls to add to it. If the trait is
761761
// documented locally though we always create the file to avoid dead
762762
// links.
763-
if implementors.is_empty() && !cache.paths.contains_key(&did) {
763+
if implementors.peek().is_none() && !cache.paths.contains_key(&did) {
764764
continue;
765765
}
766766

@@ -771,11 +771,7 @@ impl TraitAliasPart {
771771
path.push(format!("{remote_item_type}.{}.js", remote_path[remote_path.len() - 1]));
772772

773773
let part = OrderedJson::array_sorted(
774-
implementors
775-
.iter()
776-
.map(OrderedJson::serialize)
777-
.collect::<Result<Vec<_>, _>>()
778-
.unwrap(),
774+
implementors.map(|implementor| OrderedJson::serialize(implementor).unwrap()),
779775
);
780776
path_parts.push(path, OrderedJson::array_unsorted([crate_name_json, &part]));
781777
}

0 commit comments

Comments
 (0)