From fbbb543ced054daf718e6442247778713bde7008 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 3 Sep 2023 16:22:06 +1000 Subject: [PATCH] coverage: Reserve capacity for all of a function's mapping regions We already know in advance how many entries will be pushed onto this vector. --- compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs index 1ad4b249947..b9025eff82c 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs @@ -171,7 +171,7 @@ fn write_coverage_mapping<'a>( } let mut virtual_file_mapping = Vec::new(); - let mut mapping_regions = Vec::new(); + let mut mapping_regions = Vec::with_capacity(counter_regions.len()); let mut current_file_name = None; let mut current_file_id = 0;