Don't use Rc
in TokenTreeOrTokenTreeVec
.
This avoids 800,000 allocations when compiling html5ever.
This commit is contained in:
parent
3fd90d8aa5
commit
c440a7ae65
@ -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));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user