about summary refs log tree commit diff
path: root/src/libsyntax_pos
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-05-26 12:24:25 +0000
committerbors <bors@rust-lang.org>2019-05-26 12:24:25 +0000
commitdc6db14e1cd60012f25be4fd8d2eb96ea5b4bb68 (patch)
tree073b67d138399a8e9557e33ebd52bdbec9242d3a /src/libsyntax_pos
parent566f3d7b0833f06ba12280aa6ef8802732fff5c0 (diff)
parente9933ee099042d005cdba395c1027802ba40cae9 (diff)
downloadrust-dc6db14e1cd60012f25be4fd8d2eb96ea5b4bb68.tar.gz
rust-dc6db14e1cd60012f25be4fd8d2eb96ea5b4bb68.zip
Auto merge of #61210 - Centril:rollup-ofr6h5b, r=Centril
Rollup of 4 pull requests

Successful merges:

 - #61077 (Don't arena-allocate static symbols.)
 - #61102 (Move path for iterate)
 - #61120 (Make eval_place iterate instead of recurse)
 - #61205 (docs: fix typo #61197)

Failed merges:

r? @ghost
Diffstat (limited to 'src/libsyntax_pos')
-rw-r--r--src/libsyntax_pos/symbol.rs19
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 {