]> git.lizzy.rs Git - rust.git/commitdiff
Don't use `Rc` in `TokenTreeOrTokenTreeVec`.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 21 Oct 2016 10:51:15 +0000 (21:51 +1100)
committerNicholas Nethercote <nnethercote@mozilla.com>
Tue, 25 Oct 2016 01:20:14 +0000 (12:20 +1100)
This avoids 800,000 allocations when compiling html5ever.

src/libsyntax/ext/tt/macro_parser.rs

index dacc5191955657e42492fdc0db8e3a6a5a8df63e..91675065eb86e5240116ff6fbde3266ab7745100 100644 (file)
 #[derive(Clone)]
 enum TokenTreeOrTokenTreeVec {
     Tt(tokenstream::TokenTree),
-    TtSeq(Rc<Vec<tokenstream::TokenTree>>),
+    TtSeq(Vec<tokenstream::TokenTree>),
 }
 
 impl TokenTreeOrTokenTreeVec {
@@ -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();
@@ -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));