From c0602c81db55777be726cd8fe2fd074e34bd4d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Tue, 25 Jun 2024 22:38:30 +0900 Subject: [PATCH] perf(es/parser): Add a check before numeric operations (#9105) **Description:** `c.is_ascii_uppercase()` was expensive than expected. --- crates/swc_ecma_parser/src/lexer/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/swc_ecma_parser/src/lexer/mod.rs b/crates/swc_ecma_parser/src/lexer/mod.rs index 3bc354501879..ba807a39ae92 100644 --- a/crates/swc_ecma_parser/src/lexer/mod.rs +++ b/crates/swc_ecma_parser/src/lexer/mod.rs @@ -800,7 +800,7 @@ impl<'a> Lexer<'a> { loop { if let Some(c) = l.input.cur_as_ascii() { // Performance optimization - if c.is_ascii_uppercase() || c.is_ascii_digit() { + if can_be_keyword && (c.is_ascii_uppercase() || c.is_ascii_digit()) { can_be_keyword = false; }