From b497255abeddf43af51b42c0a218ad0ba05dc537 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 4 Dec 2024 18:20:38 +0100 Subject: [PATCH] perf: compact next_token --- crates/parse/src/parser/mod.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/crates/parse/src/parser/mod.rs b/crates/parse/src/parser/mod.rs index 6012da6f..9eb766ef 100644 --- a/crates/parse/src/parser/mod.rs +++ b/crates/parse/src/parser/mod.rs @@ -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.