From 9886c233d84c231030af76419d002996df981ebc Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 18 Sep 2021 18:01:36 +0200 Subject: [PATCH] Remove Symbol::len It is used exactly once and can be replaced with the equally fast .as_str().len() --- compiler/rustc_expand/src/proc_macro_server.rs | 2 +- compiler/rustc_span/src/symbol.rs | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index 52b60c3047e1c..5cb97198765fe 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -577,7 +577,7 @@ impl server::Literal for Rustc<'_> { } // Synthesize a new symbol that includes the minus sign. - let symbol = Symbol::intern(&s[..1 + lit.symbol.len()]); + let symbol = Symbol::intern(&s[..1 + lit.symbol.as_str().len()]); lit = token::Lit::new(lit.kind, symbol, lit.suffix); } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 7c2a09e0a32e0..eaf92487bfff7 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1642,10 +1642,6 @@ impl Symbol { self.0.as_u32() } - pub fn len(self) -> usize { - with_session_globals(|session_globals| session_globals.symbol_interner.get(self).len()) - } - pub fn is_empty(self) -> bool { self == kw::Empty }