Skip to content

Commit e396f99

Browse files
committed
Don't arena-allocate static symbols.
It's just a waste of memory. This also gets rid of the special case for "".
1 parent 27cc0db commit e396f99

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/libsyntax_pos/symbol.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -866,20 +866,13 @@ pub struct Interner {
866866
}
867867

868868
impl Interner {
869-
fn prefill(init: &[&str]) -> Self {
870-
let mut this = Interner::default();
871-
this.names.reserve(init.len());
872-
this.strings.reserve(init.len());
873-
874-
// We can't allocate empty strings in the arena, so handle this here.
875-
assert!(kw::Invalid.as_u32() == 0 && init[0].is_empty());
876-
this.names.insert("", kw::Invalid);
877-
this.strings.push("");
878-
879-
for string in &init[1..] {
880-
this.intern(string);
869+
fn prefill(init: &[&'static str]) -> Self {
870+
let symbols = (0 .. init.len() as u32).map(Symbol::new);
871+
Interner {
872+
strings: init.to_vec(),
873+
names: init.iter().copied().zip(symbols).collect(),
874+
..Default::default()
881875
}
882-
this
883876
}
884877

885878
pub fn intern(&mut self, string: &str) -> Symbol {

0 commit comments

Comments
 (0)