Skip to content

Commit

Permalink
Rollup merge of rust-lang#61077 - nnethercote:tweak-prefill, r=petroc…
Browse files Browse the repository at this point in the history
…henkov

Don't arena-allocate static symbols.

It's just a waste of memory. This also gets rid of the special case for
"".

r? @petrochenkov
  • Loading branch information
Centril authored May 24, 2019
2 parents fc45382 + e396f99 commit 5cbb7a1
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/libsyntax_pos/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,20 +866,13 @@ pub struct Interner {
}

impl Interner {
fn prefill(init: &[&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);
fn prefill(init: &[&'static str]) -> Self {
let symbols = (0 .. init.len() as u32).map(Symbol::new);
Interner {
strings: init.to_vec(),
names: init.iter().copied().zip(symbols).collect(),
..Default::default()
}
this
}

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

0 comments on commit 5cbb7a1

Please sign in to comment.