diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2021-06-30 18:39:28 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2021-07-06 11:28:06 +0200 |
| commit | ca935ddbf104b8b48eea8106f19e6a87f628d897 (patch) | |
| tree | e241f88eda28c661fb44767996a3bdcfe3b1bfb6 /compiler/rustc_middle | |
| parent | e95bd03f0119aff7942cbc28986e12ee42e9f6bc (diff) | |
| download | rust-ca935ddbf104b8b48eea8106f19e6a87f628d897.tar.gz rust-ca935ddbf104b8b48eea8106f19e6a87f628d897.zip | |
Make tcx.stable_crate_id() faster
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index abf839711b3..9c98592c865 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1299,8 +1299,12 @@ impl<'tcx> TyCtxt<'tcx> { } #[inline] - pub fn stable_crate_id(self, cnum: CrateNum) -> StableCrateId { - self.def_path_hash(cnum.as_def_id()).stable_crate_id() + pub fn stable_crate_id(self, crate_num: CrateNum) -> StableCrateId { + if crate_num == LOCAL_CRATE { + self.sess.local_stable_crate_id() + } else { + self.cstore.stable_crate_id_untracked(crate_num) + } } pub fn def_path_debug_str(self, def_id: DefId) -> String { |
