about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2016-10-21 19:25:16 +1100
committerNicholas Nethercote <nnethercote@mozilla.com>2016-10-25 11:48:20 +1100
commit0a16a11c392d227ca845e65905c06599579e2828 (patch)
treefed1784381bf6c5935b4dcb0e1fcb2afd7eb7432 /src/libsyntax/ext
parent1e5dab1da04143a454a4f3d7e3f835ce990b437a (diff)
downloadrust-0a16a11c392d227ca845e65905c06599579e2828.tar.gz
rust-0a16a11c392d227ca845e65905c06599579e2828.zip
Use `SmallVector` for the stack in `macro_parser::parse`.
This avoids 800,000 heap allocations when compiling html5ever.
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index 74def68b185..dacc5191955 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -92,6 +92,7 @@ use parse::token;
 use print::pprust;
 use ptr::P;
 use tokenstream::{self, TokenTree};
+use util::small_vector::SmallVector;
 
 use std::mem;
 use std::rc::Rc;
@@ -284,12 +285,9 @@ pub fn parse(sess: &ParseSess,
              mut rdr: TtReader,
              ms: &[TokenTree])
              -> NamedParseResult {
-    let mut cur_eis = Vec::new();
-    cur_eis.push(initial_matcher_pos(Rc::new(ms.iter()
-                                                .cloned()
-                                                .collect()),
-                                     None,
-                                     rdr.peek().sp.lo));
+    let mut cur_eis = SmallVector::one(initial_matcher_pos(Rc::new(ms.to_owned()),
+                                                           None,
+                                                           rdr.peek().sp.lo));
 
     loop {
         let mut bb_eis = Vec::new(); // black-box parsed by parser.rs