diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2021-11-18 20:59:12 +0000 |
|---|---|---|
| committer | Noah Lev <camelidcamel@gmail.com> | 2022-01-07 11:50:42 -0800 |
| commit | 0b1ab91d6604cf3277ef562eabd04f107015de58 (patch) | |
| tree | e9075aecdcee6fe3e2abbd01c0499adb30be2bc9 | |
| parent | e012a191d768adeda1ee36a99ef8b92d51920154 (diff) | |
| download | rust-0b1ab91d6604cf3277ef562eabd04f107015de58.tar.gz rust-0b1ab91d6604cf3277ef562eabd04f107015de58.zip | |
Deserialization less in associated_item_def_ids
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs | 7 |
2 files changed, 11 insertions, 6 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index bb9a58a0b62..5dbd26694c5 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1258,6 +1258,16 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { } } + fn get_associated_item_def_ids(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [DefId] { + if let Some(children) = self.root.tables.children.get(self, id) { + tcx.arena.alloc_from_iter( + children.decode((self, tcx.sess)).map(|child_index| self.local_def_id(child_index)), + ) + } else { + &[] + } + } + fn get_associated_item(&self, id: DefIndex, sess: &Session) -> ty::AssocItem { let def_key = self.def_key(id); let parent = self.local_def_id(def_key.parent.unwrap()); diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index aac0aa61ea6..804f277e26e 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -103,12 +103,7 @@ provide! { <'tcx> tcx, def_id, other, cdata, tcx.calculate_dtor(def_id, |_,_| Ok(())) } variances_of => { tcx.arena.alloc_from_iter(cdata.get_item_variances(def_id.index)) } - associated_item_def_ids => { - let mut result = SmallVec::<[_; 8]>::new(); - cdata.each_child_of_item(def_id.index, - |child| result.push(child.res.def_id()), tcx.sess); - tcx.arena.alloc_slice(&result) - } + associated_item_def_ids => { cdata.get_associated_item_def_ids(tcx, def_id.index) } associated_item => { cdata.get_associated_item(def_id.index, tcx.sess) } impl_trait_ref => { cdata.get_impl_trait(def_id.index, tcx) } impl_polarity => { cdata.get_impl_polarity(def_id.index) } |
