From 101cdcb2b321e4591131963f43edaf0f5128f3aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 22 Aug 2026 00:47:15 +0200 Subject: [PATCH] parser: Clean up next() a bit. No behavior change, but this is easier to reason about and profiling shows the try stuff showing up. --- src/parser.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index c68120f5..29b01a1f 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -687,11 +687,9 @@ impl<'i: 't, 't> Parser<'i, 't> { } &cached_token.token } else { - let new_token = self - .input - .tokenizer - .next() - .map_err(|()| self.new_basic_error(BasicParseErrorKind::EndOfInput))?; + let Ok(new_token) = self.input.tokenizer.next() else { + return Err(self.new_basic_error(BasicParseErrorKind::EndOfInput)); + }; self.input.cached_token = Some(CachedToken { token: new_token, start_position: token_start_position,