@@ -6,7 +6,7 @@ use llvm::coverageinfo::CounterMappingRegion;
66use log:: debug;
77use rustc_codegen_ssa:: coverageinfo:: map:: { Counter , CounterExpression , Region } ;
88use rustc_codegen_ssa:: traits:: { BaseTypeMethods , ConstMethods } ;
9- use rustc_data_structures:: fx:: FxHashMap ;
9+ use rustc_data_structures:: fx:: FxIndexSet ;
1010use rustc_llvm:: RustString ;
1111
1212use std:: ffi:: CString ;
@@ -76,13 +76,12 @@ pub fn finalize<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) {
7676}
7777
7878struct CoverageMapGenerator {
79- filenames : Vec < CString > ,
80- filename_to_index : FxHashMap < CString , u32 > ,
79+ filenames : FxIndexSet < CString > ,
8180}
8281
8382impl CoverageMapGenerator {
8483 fn new ( ) -> Self {
85- Self { filenames : Vec :: new ( ) , filename_to_index : FxHashMap :: default ( ) }
84+ Self { filenames : FxIndexSet :: default ( ) }
8685 }
8786
8887 /// Using the `expressions` and `counter_regions` collected for the current function, generate
@@ -122,16 +121,8 @@ impl CoverageMapGenerator {
122121 let c_filename =
123122 CString :: new ( file_name) . expect ( "null error converting filename to C string" ) ;
124123 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 ) ;
135126 }
136127 mapping_regions. push ( CounterMappingRegion :: code_region (
137128 counter,
0 commit comments