@@ -6,7 +6,7 @@ use llvm::coverageinfo::CounterMappingRegion;
6
6
use log:: debug;
7
7
use rustc_codegen_ssa:: coverageinfo:: map:: { Counter , CounterExpression , Region } ;
8
8
use rustc_codegen_ssa:: traits:: { BaseTypeMethods , ConstMethods } ;
9
- use rustc_data_structures:: fx:: FxHashMap ;
9
+ use rustc_data_structures:: fx:: FxIndexSet ;
10
10
use rustc_llvm:: RustString ;
11
11
12
12
use std:: ffi:: CString ;
@@ -76,13 +76,12 @@ pub fn finalize<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) {
76
76
}
77
77
78
78
struct CoverageMapGenerator {
79
- filenames : Vec < CString > ,
80
- filename_to_index : FxHashMap < CString , u32 > ,
79
+ filenames : FxIndexSet < CString > ,
81
80
}
82
81
83
82
impl CoverageMapGenerator {
84
83
fn new ( ) -> Self {
85
- Self { filenames : Vec :: new ( ) , filename_to_index : FxHashMap :: default ( ) }
84
+ Self { filenames : FxIndexSet :: default ( ) }
86
85
}
87
86
88
87
/// Using the `expressions` and `counter_regions` collected for the current function, generate
@@ -122,16 +121,8 @@ impl CoverageMapGenerator {
122
121
let c_filename =
123
122
CString :: new ( file_name) . expect ( "null error converting filename to C string" ) ;
124
123
debug ! ( " file_id: {} = '{:?}'" , current_file_id, c_filename) ;
125
- let filenames_index = match self . filename_to_index . get ( & c_filename) {
126
- Some ( index) => * index,
127
- None => {
128
- let index = self . filenames . len ( ) as u32 ;
129
- self . filenames . push ( c_filename. clone ( ) ) ;
130
- self . filename_to_index . insert ( c_filename. clone ( ) , index) ;
131
- index
132
- }
133
- } ;
134
- virtual_file_mapping. push ( filenames_index) ;
124
+ let ( filenames_index, _) = self . filenames . insert_full ( c_filename) ;
125
+ virtual_file_mapping. push ( filenames_index as u32 ) ;
135
126
}
136
127
mapping_regions. push ( CounterMappingRegion :: code_region (
137
128
counter,
0 commit comments