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)]
|
#[derive(Clone)]
|
||||||
enum TokenTreeOrTokenTreeVec {
|
enum TokenTreeOrTokenTreeVec {
|
||||||
Tt(tokenstream::TokenTree),
|
Tt(tokenstream::TokenTree),
|
||||||
TtSeq(Rc<Vec<tokenstream::TokenTree>>),
|
TtSeq(Vec<tokenstream::TokenTree>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TokenTreeOrTokenTreeVec {
|
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> {
|
-> Box<MatcherPos> {
|
||||||
let match_idx_hi = count_names(&ms[..]);
|
let match_idx_hi = count_names(&ms[..]);
|
||||||
let matches: Vec<_> = (0..match_idx_hi).map(|_| Vec::new()).collect();
|
let matches: Vec<_> = (0..match_idx_hi).map(|_| Vec::new()).collect();
|
||||||
|
@ -285,7 +285,7 @@ pub fn parse(sess: &ParseSess,
|
||||||
mut rdr: TtReader,
|
mut rdr: TtReader,
|
||||||
ms: &[TokenTree])
|
ms: &[TokenTree])
|
||||||
-> NamedParseResult {
|
-> 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,
|
None,
|
||||||
rdr.peek().sp.lo));
|
rdr.peek().sp.lo));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue