coverage: Fetch expressions and mappings separately

The combined `get_expressions_and_counter_regions` method was an artifact of
having to prepare the expressions and mappings at the same time, to avoid
ownership/lifetime problems with temporary data used by both.

Now that we have an explicit transition from `FunctionCoverageCollector` to the
final `FunctionCoverage`, we can prepare any shared data during that step and
store it in the final struct.
This commit is contained in:
Zalathar
2023-10-06 22:46:04 +11:00
parent 371883a05a
commit 86b55cccff
2 changed files with 14 additions and 28 deletions

View File

@@ -185,13 +185,13 @@ fn encode_mappings_for_function(
global_file_table: &mut GlobalFileTable,
function_coverage: &FunctionCoverage<'_>,
) -> Vec<u8> {
let (expressions, counter_regions) = function_coverage.get_expressions_and_counter_regions();
let mut counter_regions = counter_regions.collect::<Vec<_>>();
let mut counter_regions = function_coverage.counter_regions().collect::<Vec<_>>();
if counter_regions.is_empty() {
return Vec::new();
}
let expressions = function_coverage.counter_expressions().collect::<Vec<_>>();
let mut virtual_file_mapping = IndexVec::<u32, u32>::new();
let mut mapping_regions = Vec::with_capacity(counter_regions.len());