Skip to content

Commit

Permalink
perf(parser): get and check lookahead token (#4534)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucab committed Jul 29, 2024
1 parent d914b14 commit 0870ee1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/oxc_parser/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ impl<'a> Lexer<'a> {
let n = n as usize;
debug_assert!(n > 0);

if self.lookahead.len() > n - 1 {
return self.lookahead[n - 1].token;
if let Some(lookahead) = self.lookahead.get(n - 1) {
return lookahead.token;
}

let position = self.source.position();
Expand Down

0 comments on commit 0870ee1

Please sign in to comment.