Skip to content
Permalink
Browse files

Don't arena-allocate static symbols.

It's just a waste of memory. This also gets rid of the special case for
"".
  • Loading branch information...
nnethercote committed May 23, 2019
1 parent 15ccaf7 commit c3bf80757b1eaf76a54f406da1ad69be175567ab
Showing with 6 additions and 8 deletions.
  1. +6 −8 src/libsyntax_pos/symbol.rs
@@ -864,18 +864,16 @@ pub struct Interner {
}

impl Interner {
fn prefill(init: &[&str]) -> Self {
fn prefill(init: &[&'static str]) -> Self {
let mut this = Interner::default();
this.names.reserve(init.len());
this.strings.reserve(init.len());

// We can't allocate empty strings in the arena, so handle this here.
assert!(kw::Invalid.as_u32() == 0 && init[0].is_empty());
this.names.insert("", kw::Invalid);
this.strings.push("");

for string in &init[1..] {
this.intern(string);
// We avoid calling `intern` on the static symbols; that way we don't
// allocate space for them unnecessarily in the arena.
for (index, string) in init.iter().enumerate() {
this.strings.push(string);
this.names.insert(string, Symbol::new(index as u32));
}
this
}

0 comments on commit c3bf807

Please sign in to comment.
You can’t perform that action at this time.