Use an empty TokenCursorFrame
stack when capturing tokens
We will never need to pop past our starting frame during token capturing. Using an empty stack allows us to avoid pointless heap allocations/deallocations.
This commit is contained in:
parent
26438b4738
commit
7b36408b5f
1 changed files with 9 additions and 1 deletions
|
@ -1239,7 +1239,15 @@ impl<'a> Parser<'a> {
|
|||
f: impl FnOnce(&mut Self) -> PResult<'a, R>,
|
||||
) -> PResult<'a, (R, Option<LazyTokenStream>)> {
|
||||
let start_token = (self.token.clone(), self.token_spacing);
|
||||
let cursor_snapshot = self.token_cursor.clone();
|
||||
let cursor_snapshot = TokenCursor {
|
||||
frame: self.token_cursor.frame.clone(),
|
||||
// We only ever capture tokens within our current frame,
|
||||
// so we can just use an empty frame stack
|
||||
stack: vec![],
|
||||
desugar_doc_comments: self.token_cursor.desugar_doc_comments,
|
||||
num_next_calls: self.token_cursor.num_next_calls,
|
||||
append_unglued_token: self.token_cursor.append_unglued_token.clone(),
|
||||
};
|
||||
|
||||
let ret = f(self)?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue