@@ -146,25 +146,30 @@ impl<'hir> Iterator for ParentOwnerIterator<'hir> {
146146}
147147
148148impl < ' hir > Map < ' hir > {
149+ #[ inline]
149150 pub fn krate ( self ) -> & ' hir Crate < ' hir > {
150151 self . tcx . hir_crate ( ( ) )
151152 }
152153
154+ #[ inline]
153155 pub fn root_module ( self ) -> & ' hir Mod < ' hir > {
154156 match self . tcx . hir_owner ( CRATE_DEF_ID ) . map ( |o| o. node ) {
155157 Some ( OwnerNode :: Crate ( item) ) => item,
156158 _ => bug ! ( ) ,
157159 }
158160 }
159161
162+ #[ inline]
160163 pub fn items ( self ) -> impl Iterator < Item = ItemId > + ' hir {
161164 self . tcx . hir_crate_items ( ( ) ) . items . iter ( ) . copied ( )
162165 }
163166
167+ #[ inline]
164168 pub fn module_items ( self , module : LocalDefId ) -> impl Iterator < Item = ItemId > + ' hir {
165169 self . tcx . hir_module_items ( module) . items ( )
166170 }
167171
172+ #[ inline]
168173 pub fn par_for_each_item ( self , f : impl Fn ( ItemId ) + Sync + Send ) {
169174 par_for_each_in ( & self . tcx . hir_crate_items ( ( ) ) . items [ ..] , |id| f ( * id) ) ;
170175 }
@@ -489,11 +494,13 @@ impl<'hir> Map<'hir> {
489494 /// Returns an iterator of the `DefId`s for all body-owners in this
490495 /// crate. If you would prefer to iterate over the bodies
491496 /// themselves, you can do `self.hir().krate().body_ids.iter()`.
497+ #[ inline]
492498 pub fn body_owners ( self ) -> impl Iterator < Item = LocalDefId > + ' hir {
493499 self . tcx . hir_crate_items ( ( ) ) . body_owners . iter ( ) . copied ( )
494500 }
495501
496- pub fn par_body_owners < F : Fn ( LocalDefId ) + Sync + Send > ( self , f : F ) {
502+ #[ inline]
503+ pub fn par_body_owners ( self , f : impl Fn ( LocalDefId ) + Sync + Send ) {
497504 par_for_each_in ( & self . tcx . hir_crate_items ( ( ) ) . body_owners [ ..] , |& def_id| f ( def_id) ) ;
498505 }
499506
@@ -626,35 +633,22 @@ impl<'hir> Map<'hir> {
626633 }
627634 }
628635
629- #[ cfg( not( parallel_compiler) ) ]
630636 #[ inline]
631- pub fn par_for_each_module ( self , f : impl Fn ( LocalDefId ) ) {
632- self . for_each_module ( f)
633- }
634-
635- #[ cfg( parallel_compiler) ]
636- pub fn par_for_each_module ( self , f : impl Fn ( LocalDefId ) + Sync ) {
637- use rustc_data_structures:: sync:: { par_iter, ParallelIterator } ;
638- par_iter_submodules ( self . tcx , CRATE_DEF_ID , & f) ;
639-
640- fn par_iter_submodules < F > ( tcx : TyCtxt < ' _ > , module : LocalDefId , f : & F )
641- where
642- F : Fn ( LocalDefId ) + Sync ,
643- {
644- ( * f) ( module) ;
645- let items = tcx. hir_module_items ( module) ;
646- par_iter ( & items. submodules [ ..] ) . for_each ( |& sm| par_iter_submodules ( tcx, sm, f) ) ;
647- }
637+ pub fn par_for_each_module ( self , f : impl Fn ( LocalDefId ) + Sync + Send ) {
638+ let crate_items = self . tcx . hir_crate_items ( ( ) ) ;
639+ par_for_each_in ( & crate_items. submodules [ ..] , |module| f ( * module) )
648640 }
649641
650642 /// Returns an iterator for the nodes in the ancestor tree of the `current_id`
651643 /// until the crate root is reached. Prefer this over your own loop using `get_parent_node`.
644+ #[ inline]
652645 pub fn parent_iter ( self , current_id : HirId ) -> ParentHirIterator < ' hir > {
653646 ParentHirIterator { current_id, map : self }
654647 }
655648
656649 /// Returns an iterator for the nodes in the ancestor tree of the `current_id`
657650 /// until the crate root is reached. Prefer this over your own loop using `get_parent_node`.
651+ #[ inline]
658652 pub fn parent_owner_iter ( self , current_id : HirId ) -> ParentOwnerIterator < ' hir > {
659653 ParentOwnerIterator { current_id, map : self }
660654 }
0 commit comments