Rollup merge of #52703 - ljedrz:vec_improvements, r=nikomatsakis
Improve a few vectors - calculate capacity or build from iterators Collecting from iterators improves readability and tailoring vector capacities should be beneficial in terms of performance.
This commit is contained in:
commit
7da22148ec
6 changed files with 14 additions and 21 deletions
|
@ -632,15 +632,14 @@ impl MultiSpan {
|
|||
/// `SpanLabel` instances with empty labels.
|
||||
pub fn span_labels(&self) -> Vec<SpanLabel> {
|
||||
let is_primary = |span| self.primary_spans.contains(&span);
|
||||
let mut span_labels = vec![];
|
||||
|
||||
for &(span, ref label) in &self.span_labels {
|
||||
span_labels.push(SpanLabel {
|
||||
let mut span_labels = self.span_labels.iter().map(|&(span, ref label)|
|
||||
SpanLabel {
|
||||
span,
|
||||
is_primary: is_primary(span),
|
||||
label: Some(label.clone())
|
||||
});
|
||||
}
|
||||
}
|
||||
).collect::<Vec<_>>();
|
||||
|
||||
for &span in &self.primary_spans {
|
||||
if !span_labels.iter().any(|sl| sl.span == span) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue