diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-05-14 14:55:15 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-05-20 09:17:00 +1000 |
| commit | 257eaf523f7faabfc9845a238ec3776fc45fcd81 (patch) | |
| tree | 1d863bfd60039acbd2611d740653bfdd8277a355 /src/librustc_codegen_utils | |
| parent | b96be5b1889a28d0d44b54a18c8d0467da109656 (diff) | |
| download | rust-257eaf523f7faabfc9845a238ec3776fc45fcd81.tar.gz rust-257eaf523f7faabfc9845a238ec3776fc45fcd81.zip | |
Introduce `InternedString::intern`.
`InternedString::intern(x)` is preferable to `Symbol::intern(x).as_interned_str()`, because the former involves one call to `with_interner` while the latter involves two. The case within InternedString::decode() is particularly hot, and this change reduces the number of `with_interner` calls by up to 13%.
Diffstat (limited to 'src/librustc_codegen_utils')
| -rw-r--r-- | src/librustc_codegen_utils/symbol_names.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index d50a9a1607b..6915687ceba 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -101,7 +101,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_mir::monomorphize::item::{InstantiationMode, MonoItem, MonoItemExt}; use rustc_mir::monomorphize::Instance; -use syntax_pos::symbol::{Symbol, InternedString}; +use syntax_pos::symbol::InternedString; use log::debug; @@ -238,13 +238,13 @@ fn compute_symbol_name(tcx: TyCtxt<'_, 'tcx, 'tcx>, instance: Instance<'tcx>) -> if def_id.is_local() { if tcx.plugin_registrar_fn(LOCAL_CRATE) == Some(def_id) { let disambiguator = tcx.sess.local_crate_disambiguator(); - return Symbol::intern(&tcx.sess.generate_plugin_registrar_symbol(disambiguator)) - .as_interned_str(); + return + InternedString::intern(&tcx.sess.generate_plugin_registrar_symbol(disambiguator)); } if tcx.proc_macro_decls_static(LOCAL_CRATE) == Some(def_id) { let disambiguator = tcx.sess.local_crate_disambiguator(); - return Symbol::intern(&tcx.sess.generate_proc_macro_decls_symbol(disambiguator)) - .as_interned_str(); + return + InternedString::intern(&tcx.sess.generate_proc_macro_decls_symbol(disambiguator)); } } @@ -322,7 +322,7 @@ fn compute_symbol_name(tcx: TyCtxt<'_, 'tcx, 'tcx>, instance: Instance<'tcx>) -> let _ = printer.write_str("{{vtable-shim}}"); } - Symbol::intern(&printer.path.finish(hash)).as_interned_str() + InternedString::intern(&printer.path.finish(hash)) } // Follow C++ namespace-mangling style, see |
