@@ -8,8 +8,8 @@ use crate::ich::Fingerprint;
88use crate :: middle:: cstore:: CrateStore ;
99use crate :: session:: CrateDisambiguator ;
1010use crate :: session:: Session ;
11- use std :: iter :: repeat ;
12- use syntax:: ast:: { NodeId , CRATE_NODE_ID } ;
11+ use crate :: util :: nodemap :: FxHashMap ;
12+ use syntax:: ast:: NodeId ;
1313use syntax:: source_map:: SourceMap ;
1414use syntax_pos:: Span ;
1515
@@ -25,7 +25,7 @@ pub(super) struct NodeCollector<'a, 'hir> {
2525 source_map : & ' a SourceMap ,
2626
2727 /// The node map
28- map : Vec < Option < Entry < ' hir > > > ,
28+ map : FxHashMap < HirId , Entry < ' hir > > ,
2929 /// The parent of this node
3030 parent_node : hir:: HirId ,
3131
@@ -146,7 +146,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
146146 let mut collector = NodeCollector {
147147 krate,
148148 source_map : sess. source_map ( ) ,
149- map : repeat ( None ) . take ( sess . current_node_id_count ( ) ) . collect ( ) ,
149+ map : Default :: default ( ) ,
150150 parent_node : hir:: CRATE_HIR_ID ,
151151 current_signature_dep_index : root_mod_sig_dep_index,
152152 current_full_dep_index : root_mod_full_dep_index,
@@ -158,9 +158,8 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
158158 hcx,
159159 hir_body_nodes,
160160 } ;
161- collector. insert_entry ( CRATE_NODE_ID , Entry {
162- parent : CRATE_NODE_ID ,
163- parent_hir : hir:: CRATE_HIR_ID ,
161+ collector. insert_entry ( hir:: CRATE_HIR_ID , Entry {
162+ parent : hir:: CRATE_HIR_ID ,
164163 dep_node : root_mod_sig_dep_index,
165164 node : Node :: Crate ,
166165 } ) ;
@@ -172,7 +171,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
172171 crate_disambiguator : CrateDisambiguator ,
173172 cstore : & dyn CrateStore ,
174173 commandline_args_hash : u64 )
175- -> ( Vec < Option < Entry < ' hir > > > , Svh )
174+ -> ( FxHashMap < HirId , Entry < ' hir > > , Svh )
176175 {
177176 self . hir_body_nodes . sort_unstable_by_key ( |bn| bn. 0 ) ;
178177
@@ -223,15 +222,14 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
223222 ( self . map , svh)
224223 }
225224
226- fn insert_entry ( & mut self , id : NodeId , entry : Entry < ' hir > ) {
225+ fn insert_entry ( & mut self , id : HirId , entry : Entry < ' hir > ) {
227226 debug ! ( "hir_map: {:?} => {:?}" , id, entry) ;
228- self . map [ id . as_usize ( ) ] = Some ( entry) ;
227+ self . map . insert ( id , entry) ;
229228 }
230229
231230 fn insert ( & mut self , span : Span , hir_id : HirId , node : Node < ' hir > ) {
232231 let entry = Entry {
233- parent : self . hir_to_node_id [ & self . parent_node ] ,
234- parent_hir : self . parent_node ,
232+ parent : self . parent_node ,
235233 dep_node : if self . currently_in_body {
236234 self . current_full_dep_index
237235 } else {
@@ -240,12 +238,11 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
240238 node,
241239 } ;
242240
243- let node_id = self . hir_to_node_id [ & hir_id] ;
244-
245241 // Make sure that the DepNode of some node coincides with the HirId
246242 // owner of that node.
247243 if cfg ! ( debug_assertions) {
248- assert_eq ! ( self . definitions. node_to_hir_id( node_id) , hir_id) ;
244+ let node_id = self . hir_to_node_id [ & hir_id] ;
245+ assert_eq ! ( self . definitions. node_to_hir_id( node_id) , hir_id) ;
249246
250247 if hir_id. owner != self . current_dep_node_owner {
251248 let node_str = match self . definitions . opt_def_index ( node_id) {
@@ -278,7 +275,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
278275 }
279276 }
280277
281- self . insert_entry ( node_id , entry) ;
278+ self . insert_entry ( hir_id , entry) ;
282279 }
283280
284281 fn with_parent < F : FnOnce ( & mut Self ) > (
0 commit comments