fix perf issue in macro parser
For a fuller description of the performance issue fixed by this: https://github.com/rust-lang/rust/issues/51754#issuecomment-403242159
This commit is contained in:
parent
9fd3d7899a
commit
191e76c5b8
1 changed files with 8 additions and 1 deletions
|
@ -696,10 +696,17 @@ pub fn parse(
|
||||||
} else {
|
} else {
|
||||||
return Failure(parser.span, token::Eof);
|
return Failure(parser.span, token::Eof);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Performance hack: eof_items may share matchers via Rc with other things that we want
|
||||||
|
// to modify. Dropping eof_items now may drop these refcounts to 1, preventing an
|
||||||
|
// unnecessary implicit clone later in Rc::make_mut.
|
||||||
|
drop(eof_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Another possibility is that we need to call out to parse some rust nonterminal
|
// Another possibility is that we need to call out to parse some rust nonterminal
|
||||||
// (black-box) parser. However, if there is not EXACTLY ONE of these, something is wrong.
|
// (black-box) parser. However, if there is not EXACTLY ONE of these, something is wrong.
|
||||||
else if (!bb_items.is_empty() && !next_items.is_empty()) || bb_items.len() > 1 {
|
assert!(!token_name_eq(&parser.token, &token::Eof));
|
||||||
|
if (!bb_items.is_empty() && !next_items.is_empty()) || bb_items.len() > 1 {
|
||||||
let nts = bb_items
|
let nts = bb_items
|
||||||
.iter()
|
.iter()
|
||||||
.map(|item| match item.top_elts.get_tt(item.idx) {
|
.map(|item| match item.top_elts.get_tt(item.idx) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue