perf(parser): get and check lookahead token (#4534)

This commit is contained in:
lucab 2024-07-29 16:45:39 +00:00
parent d914b14275
commit 0870ee1f9f

View file

@ -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();