Skip to content

Commit

Permalink
Don't use Rc in TokenTreeOrTokenTreeVec.
Browse files Browse the repository at this point in the history
This avoids 800,000 allocations when compiling html5ever.
  • Loading branch information
nnethercote committed Oct 25, 2016
1 parent 3fd90d8 commit c440a7a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libsyntax/ext/tt/macro_parser.rs
Expand Up @@ -105,7 +105,7 @@ use std::collections::hash_map::Entry::{Vacant, Occupied};
#[derive(Clone)]
enum TokenTreeOrTokenTreeVec {
Tt(tokenstream::TokenTree),
TtSeq(Rc<Vec<tokenstream::TokenTree>>),
TtSeq(Vec<tokenstream::TokenTree>),
}

impl TokenTreeOrTokenTreeVec {
Expand Down Expand Up @@ -162,7 +162,7 @@ pub fn count_names(ms: &[TokenTree]) -> usize {
})
}

pub fn initial_matcher_pos(ms: Rc<Vec<TokenTree>>, sep: Option<Token>, lo: BytePos)
pub fn initial_matcher_pos(ms: Vec<TokenTree>, sep: Option<Token>, lo: BytePos)
-> Box<MatcherPos> {
let match_idx_hi = count_names(&ms[..]);
let matches: Vec<_> = (0..match_idx_hi).map(|_| Vec::new()).collect();
Expand Down Expand Up @@ -285,7 +285,7 @@ pub fn parse(sess: &ParseSess,
mut rdr: TtReader,
ms: &[TokenTree])
-> NamedParseResult {
let mut cur_eis = SmallVector::one(initial_matcher_pos(Rc::new(ms.to_owned()),
let mut cur_eis = SmallVector::one(initial_matcher_pos(ms.to_owned(),
None,
rdr.peek().sp.lo));

Expand Down

0 comments on commit c440a7a

Please sign in to comment.