about summary refs log tree commit diff
path: root/src/libsyntax_pos
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-05-10 16:57:15 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-05-10 17:08:22 +0300
commitaeee1fb1f250accccd85f8d7f7a501ed81db68e8 (patch)
treef0c0bcd0b25b948b85e0e5674f4409a8a98270b3 /src/libsyntax_pos
parent0ac53da03dad79655e2f3e65a58f94a2f3314d5f (diff)
downloadrust-aeee1fb1f250accccd85f8d7f7a501ed81db68e8.tar.gz
rust-aeee1fb1f250accccd85f8d7f7a501ed81db68e8.zip
syntax_pos: Optimize symbol interner pre-filling slightly
Diffstat (limited to 'src/libsyntax_pos')
-rw-r--r--src/libsyntax_pos/symbol.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs
index 20759217b54..23ab3e2bf94 100644
--- a/src/libsyntax_pos/symbol.rs
+++ b/src/libsyntax_pos/symbol.rs
@@ -453,15 +453,16 @@ pub struct Interner {
 impl Interner {
     fn prefill(init: &[&str]) -> Self {
         let mut this = Interner::default();
-        for &string in init {
-            if string == "" {
-                // We can't allocate empty strings in the arena, so handle this here.
-                let name = Symbol::new(this.strings.len() as u32);
-                this.names.insert("", name);
-                this.strings.push("");
-            } else {
-                this.intern(string);
-            }
+        this.names.reserve(init.len());
+        this.strings.reserve(init.len());
+
+        // We can't allocate empty strings in the arena, so handle this here.
+        assert!(keywords::Invalid.name().as_u32() == 0 && init[0].is_empty());
+        this.names.insert("", keywords::Invalid.name());
+        this.strings.push("");
+
+        for string in &init[1..] {
+            this.intern(string);
         }
         this
     }