Skip to content

Commit cb3df68

Browse files
committed
Streamline CrateMetadataRef construction in provide_one!.
`cstore.get_crate_data()` creates a `CrateMetadataRef`, which is exactly what we need. The current code is very confused and does several unnecessary things: mapping the `FreezeReadGuard` and calling `CStore::from_tcx` a second time to construct a second `CrateMetadataRef`. This is a small perf win.
1 parent c28e303 commit cb3df68

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,8 @@ macro_rules! provide_one {
152152
$tcx.ensure_ok().crate_hash($def_id.krate);
153153
}
154154

155-
let cdata = rustc_data_structures::sync::FreezeReadGuard::map(CStore::from_tcx($tcx), |c| {
156-
c.get_crate_data($def_id.krate).cdata
157-
});
158-
let $cdata = crate::creader::CrateMetadataRef {
159-
cdata: &cdata,
160-
cstore: &CStore::from_tcx($tcx),
161-
};
155+
let cstore = CStore::from_tcx($tcx);
156+
let $cdata = cstore.get_crate_data($def_id.krate);
162157

163158
$compute
164159
}

0 commit comments

Comments
 (0)