diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-05-23 17:47:53 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-05-24 20:11:52 +1000 |
| commit | e396f992558746689e1d562c5a6bb0b92bf70b93 (patch) | |
| tree | f9062228e68f0a8062ed1209a33d94f0c5d3b772 | |
| parent | 27cc0db7a248308fc2634ac68d7608a20b4a1c09 (diff) | |
| download | rust-e396f992558746689e1d562c5a6bb0b92bf70b93.tar.gz rust-e396f992558746689e1d562c5a6bb0b92bf70b93.zip | |
Don't arena-allocate static symbols.
It's just a waste of memory. This also gets rid of the special case for "".
| -rw-r--r-- | src/libsyntax_pos/symbol.rs | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index b1e1a056db4..26422e891c5 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -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 { |
