1
Fork 0

Rollup merge of #93234 - mati865:mir-transform-use-itertools, r=jackh726

rustc_mir_itertools: Avoid needless `collect` with itertools

I don't think this should have measurable perf impact (at least not on perf.rlo benchmarks), it's mostly for readability.
This commit is contained in:
Matthias Krüger 2022-01-23 20:13:08 +01:00 committed by GitHub
commit eea833f5f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 22 deletions

View file

@ -111,6 +111,7 @@
use super::graph::{BasicCoverageBlock, BasicCoverageBlockData, CoverageGraph};
use super::spans::CoverageSpan;
use itertools::Itertools;
use rustc_middle::mir::create_dump_file;
use rustc_middle::mir::generic_graphviz::GraphvizWriter;
use rustc_middle::mir::spanview::{self, SpanViewable};
@ -739,7 +740,6 @@ pub(super) fn dump_coverage_graphviz<'tcx>(
)
}
})
.collect::<Vec<_>>()
.join("\n ")
));
}
@ -768,7 +768,6 @@ fn bcb_to_string_sections<'tcx>(
.map(|expression| {
format!("Intermediate {}", debug_counters.format_counter(expression))
})
.collect::<Vec<_>>()
.join("\n"),
);
}
@ -783,7 +782,6 @@ fn bcb_to_string_sections<'tcx>(
covspan.format(tcx, mir_body)
)
})
.collect::<Vec<_>>()
.join("\n"),
);
}
@ -793,7 +791,6 @@ fn bcb_to_string_sections<'tcx>(
dependency_counters
.iter()
.map(|counter| debug_counters.format_counter(counter))
.collect::<Vec<_>>()
.join(" \n"),
));
}

View file

@ -1,5 +1,6 @@
use super::Error;
use itertools::Itertools;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::graph::dominators::{self, Dominators};
use rustc_data_structures::graph::{self, GraphSuccessors, WithNumNodes, WithStartNode};
@ -422,14 +423,7 @@ impl BasicCoverageBlockData {
}
pub fn id(&self) -> String {
format!(
"@{}",
self.basic_blocks
.iter()
.map(|bb| bb.index().to_string())
.collect::<Vec<_>>()
.join(ID_SEPARATOR)
)
format!("@{}", self.basic_blocks.iter().map(|bb| bb.index().to_string()).join(ID_SEPARATOR))
}
}

View file

@ -1,6 +1,7 @@
use super::debug::term_type;
use super::graph::{BasicCoverageBlock, BasicCoverageBlockData, CoverageGraph, START_BCB};
use itertools::Itertools;
use rustc_data_structures::graph::WithNumNodes;
use rustc_middle::mir::spanview::source_range_no_file;
use rustc_middle::mir::{
@ -169,11 +170,7 @@ impl CoverageSpan {
CoverageStatement::Statement(bb, _, index) => (bb, index),
CoverageStatement::Terminator(bb, _) => (bb, usize::MAX),
});
sorted_coverage_statements
.iter()
.map(|covstmt| covstmt.format(tcx, mir_body))
.collect::<Vec<_>>()
.join("\n")
sorted_coverage_statements.iter().map(|covstmt| covstmt.format(tcx, mir_body)).join("\n")
}
/// If the span is part of a macro, returns the macro name symbol.

View file

@ -31,6 +31,7 @@ use super::spans;
use coverage_test_macros::let_bcb;
use itertools::Itertools;
use rustc_data_structures::graph::WithNumNodes;
use rustc_data_structures::graph::WithSuccessors;
use rustc_index::vec::{Idx, IndexVec};
@ -232,11 +233,9 @@ fn print_mir_graphviz(name: &str, mir_body: &Body<'_>) {
mir_body
.successors(bb)
.map(|successor| { format!(" {:?} -> {:?};", bb, successor) })
.collect::<Vec<_>>()
.join("\n")
)
})
.collect::<Vec<_>>()
.join("\n")
);
}
@ -262,11 +261,9 @@ fn print_coverage_graphviz(
basic_coverage_blocks
.successors(bcb)
.map(|successor| { format!(" {:?} -> {:?};", bcb, successor) })
.collect::<Vec<_>>()
.join("\n")
)
})
.collect::<Vec<_>>()
.join("\n")
);
}