diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-07-30 22:44:49 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-07-30 22:44:49 +0200 |
| commit | 4c5ec30342fdf15d939d714f6292fd307994d535 (patch) | |
| tree | 1a0401f38039eb09f2528e75853251f059a4a5ee | |
| parent | 905834232bf7da7ae2b282806b9de4f102040d1d (diff) | |
| download | rust-4c5ec30342fdf15d939d714f6292fd307994d535.tar.gz rust-4c5ec30342fdf15d939d714f6292fd307994d535.zip | |
Inline a few short methods.
| -rw-r--r-- | compiler/rustc_middle/src/hir/map/mod.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index fa64b98d62f..127c8b58cc7 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -146,10 +146,12 @@ impl<'hir> Iterator for ParentOwnerIterator<'hir> { } impl<'hir> Map<'hir> { + #[inline] pub fn krate(self) -> &'hir Crate<'hir> { self.tcx.hir_crate(()) } + #[inline] pub fn root_module(self) -> &'hir Mod<'hir> { match self.tcx.hir_owner(CRATE_DEF_ID).map(|o| o.node) { Some(OwnerNode::Crate(item)) => item, @@ -157,14 +159,17 @@ impl<'hir> Map<'hir> { } } + #[inline] pub fn items(self) -> impl Iterator<Item = ItemId> + 'hir { self.tcx.hir_crate_items(()).items.iter().copied() } + #[inline] pub fn module_items(self, module: LocalDefId) -> impl Iterator<Item = ItemId> + 'hir { self.tcx.hir_module_items(module).items() } + #[inline] pub fn par_for_each_item(self, f: impl Fn(ItemId) + Sync + Send) { par_for_each_in(&self.tcx.hir_crate_items(()).items[..], |id| f(*id)); } @@ -487,10 +492,12 @@ impl<'hir> Map<'hir> { /// Returns an iterator of the `DefId`s for all body-owners in this /// crate. If you would prefer to iterate over the bodies /// themselves, you can do `self.hir().krate().body_ids.iter()`. + #[inline] pub fn body_owners(self) -> impl Iterator<Item = LocalDefId> + 'hir { self.tcx.hir_crate_items(()).body_owners.iter().copied() } + #[inline] pub fn par_body_owners(self, f: impl Fn(LocalDefId) + Sync + Send) { par_for_each_in(&self.tcx.hir_crate_items(()).body_owners[..], |&def_id| f(def_id)); } @@ -632,12 +639,14 @@ impl<'hir> Map<'hir> { /// Returns an iterator for the nodes in the ancestor tree of the `current_id` /// until the crate root is reached. Prefer this over your own loop using `get_parent_node`. + #[inline] pub fn parent_iter(self, current_id: HirId) -> ParentHirIterator<'hir> { ParentHirIterator { current_id, map: self } } /// Returns an iterator for the nodes in the ancestor tree of the `current_id` /// until the crate root is reached. Prefer this over your own loop using `get_parent_node`. + #[inline] pub fn parent_owner_iter(self, current_id: HirId) -> ParentOwnerIterator<'hir> { ParentOwnerIterator { current_id, map: self } } |
