diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2016-10-21 21:51:15 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2016-10-25 12:20:14 +1100 |
| commit | c440a7ae654fb641e68a9ee53b03bf3f7133c2fe (patch) | |
| tree | 41ad7d49638601952cc091f49381055a55721017 /src/libsyntax | |
| parent | 3fd90d8aa53d73456b5df476a2bd6cc2caf473c6 (diff) | |
| download | rust-c440a7ae654fb641e68a9ee53b03bf3f7133c2fe.tar.gz rust-c440a7ae654fb641e68a9ee53b03bf3f7133c2fe.zip | |
Don't use `Rc` in `TokenTreeOrTokenTreeVec`.
This avoids 800,000 allocations when compiling html5ever.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index dacc5191955..91675065eb8 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -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 { @@ -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)); |
