Skip to content

Commit 0a16a11

Browse files
committed
Use SmallVector for the stack in macro_parser::parse.
This avoids 800,000 heap allocations when compiling html5ever.
1 parent 1e5dab1 commit 0a16a11

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/libsyntax/ext/tt/macro_parser.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ use parse::token;
9292
use print::pprust;
9393
use ptr::P;
9494
use tokenstream::{self, TokenTree};
95+
use util::small_vector::SmallVector;
9596

9697
use std::mem;
9798
use std::rc::Rc;
@@ -284,12 +285,9 @@ pub fn parse(sess: &ParseSess,
284285
mut rdr: TtReader,
285286
ms: &[TokenTree])
286287
-> NamedParseResult {
287-
let mut cur_eis = Vec::new();
288-
cur_eis.push(initial_matcher_pos(Rc::new(ms.iter()
289-
.cloned()
290-
.collect()),
291-
None,
292-
rdr.peek().sp.lo));
288+
let mut cur_eis = SmallVector::one(initial_matcher_pos(Rc::new(ms.to_owned()),
289+
None,
290+
rdr.peek().sp.lo));
293291

294292
loop {
295293
let mut bb_eis = Vec::new(); // black-box parsed by parser.rs

0 commit comments

Comments
 (0)