mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Auto merge of #155628 - nnethercote:CStore-from_tcx, r=mu001999
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. r? @mu001999
This commit is contained in:
@@ -152,13 +152,8 @@ fn $name<'tcx>(
|
||||
$tcx.ensure_ok().crate_hash($def_id.krate);
|
||||
}
|
||||
|
||||
let cdata = rustc_data_structures::sync::FreezeReadGuard::map(CStore::from_tcx($tcx), |c| {
|
||||
c.get_crate_data($def_id.krate).cdata
|
||||
});
|
||||
let $cdata = crate::creader::CrateMetadataRef {
|
||||
cdata: &cdata,
|
||||
cstore: &CStore::from_tcx($tcx),
|
||||
};
|
||||
let cstore = CStore::from_tcx($tcx);
|
||||
let $cdata = cstore.get_crate_data($def_id.krate);
|
||||
|
||||
$compute
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user