Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5cbb7a1

Browse files
authoredMay 24, 2019
Rollup merge of rust-lang#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
2 parents fc45382 + e396f99 commit 5cbb7a1

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)
Please sign in to comment.