Rollup merge of #61077 - nnethercote:tweak-prefill, r=petrochenkov

Don't arena-allocate static symbols.

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

r? @petrochenkov
This commit is contained in:
Mazdak Farrokhzad 2019-05-26 13:37:55 +02:00 committed by GitHub
commit 58eb22fdae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {