Skip to content

Commit

Permalink
perf: compact next_token
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Dec 4, 2024
1 parent a6ca2a9 commit b497255
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions crates/parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,12 +757,7 @@ impl<'sess, 'ast> Parser<'sess, 'ast> {
/// Use [`bump`](Self::bump) and [`token`](Self::token) instead.
#[inline(always)]
fn next_token(&mut self) -> Token {
let mut next = self.tokens.next().unwrap_or(Token::EOF);
// Tweak the location for better diagnostics.
if next.span.is_dummy() {
next.span = self.token.span;
}
next
self.tokens.next().unwrap_or(Token { kind: TokenKind::Eof, span: self.token.span })
}

/// Returns the token `dist` tokens ahead of the current one.
Expand Down

0 comments on commit b497255

Please sign in to comment.