Skip to content

Commit 0ad8981

Browse files
committed
Inline with_interner
1 parent 05c09cb commit 0ad8981

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

compiler/rustc_span/src/symbol.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -1624,14 +1624,15 @@ impl Symbol {
16241624

16251625
/// Maps a string to its interned representation.
16261626
pub fn intern(string: &str) -> Self {
1627-
with_interner(|interner| interner.intern(string))
1627+
with_session_globals(|session_globals| session_globals.symbol_interner.intern(string))
16281628
}
16291629

16301630
/// Convert to a `SymbolStr`. This is a slowish operation because it
16311631
/// requires locking the symbol interner.
16321632
pub fn as_str(self) -> SymbolStr {
1633-
with_interner(|interner| unsafe {
1634-
SymbolStr { string: std::mem::transmute::<&str, &str>(interner.get(self)) }
1633+
with_session_globals(|session_globals| {
1634+
let symbol_str = session_globals.symbol_interner.get(self);
1635+
unsafe { SymbolStr { string: std::mem::transmute::<&str, &str>(symbol_str) } }
16351636
})
16361637
}
16371638

@@ -1640,7 +1641,7 @@ impl Symbol {
16401641
}
16411642

16421643
pub fn len(self) -> usize {
1643-
with_interner(|interner| interner.get(self).len())
1644+
with_session_globals(|session_globals| session_globals.symbol_interner.get(self).len())
16441645
}
16451646

16461647
pub fn is_empty(self) -> bool {
@@ -1879,11 +1880,6 @@ impl Ident {
18791880
}
18801881
}
18811882

1882-
#[inline]
1883-
fn with_interner<T, F: FnOnce(&Interner) -> T>(f: F) -> T {
1884-
with_session_globals(|session_globals| f(&session_globals.symbol_interner))
1885-
}
1886-
18871883
/// An alternative to [`Symbol`], useful when the chars within the symbol need to
18881884
/// be accessed. It deliberately has limited functionality and should only be
18891885
/// used for temporary values.

0 commit comments

Comments
 (0)