Skip to content

Commit 0b1ab91

Browse files
matthewjaspercamelid
authored andcommitted
Deserialization less in associated_item_def_ids
1 parent e012a19 commit 0b1ab91

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,16 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12581258
}
12591259
}
12601260

1261+
fn get_associated_item_def_ids(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [DefId] {
1262+
if let Some(children) = self.root.tables.children.get(self, id) {
1263+
tcx.arena.alloc_from_iter(
1264+
children.decode((self, tcx.sess)).map(|child_index| self.local_def_id(child_index)),
1265+
)
1266+
} else {
1267+
&[]
1268+
}
1269+
}
1270+
12611271
fn get_associated_item(&self, id: DefIndex, sess: &Session) -> ty::AssocItem {
12621272
let def_key = self.def_key(id);
12631273
let parent = self.local_def_id(def_key.parent.unwrap());

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
103103
tcx.calculate_dtor(def_id, |_,_| Ok(()))
104104
}
105105
variances_of => { tcx.arena.alloc_from_iter(cdata.get_item_variances(def_id.index)) }
106-
associated_item_def_ids => {
107-
let mut result = SmallVec::<[_; 8]>::new();
108-
cdata.each_child_of_item(def_id.index,
109-
|child| result.push(child.res.def_id()), tcx.sess);
110-
tcx.arena.alloc_slice(&result)
111-
}
106+
associated_item_def_ids => { cdata.get_associated_item_def_ids(tcx, def_id.index) }
112107
associated_item => { cdata.get_associated_item(def_id.index, tcx.sess) }
113108
impl_trait_ref => { cdata.get_impl_trait(def_id.index, tcx) }
114109
impl_polarity => { cdata.get_impl_polarity(def_id.index) }

0 commit comments

Comments
 (0)