From bf886bac73ad348ab7bc333e6eae824c96e9abde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Wed, 20 Oct 2021 00:00:48 +0900 Subject: [PATCH] perf(es/parser): Make typescript parser faster (#2483) swc_ecma_parser: - Check for option before backtracking. --- Cargo.lock | 2 +- ecmascript/parser/Cargo.toml | 2 +- ecmascript/parser/src/parser/expr.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5bd3df2dc83..1fd4133fb2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2710,7 +2710,7 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.75.0" +version = "0.75.1" dependencies = [ "either", "enum_kind", diff --git a/ecmascript/parser/Cargo.toml b/ecmascript/parser/Cargo.toml index be51a68c47f..409d93b9bb4 100644 --- a/ecmascript/parser/Cargo.toml +++ b/ecmascript/parser/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "examples/**/*.rs"] license = "Apache-2.0/MIT" name = "swc_ecma_parser" repository = "https://github.com/swc-project/swc.git" -version = "0.75.0" +version = "0.75.1" [package.metadata.docs.rs] all-features = true diff --git a/ecmascript/parser/src/parser/expr.rs b/ecmascript/parser/src/parser/expr.rs index 291d1c38659..49eacd6b78e 100644 --- a/ecmascript/parser/src/parser/expr.rs +++ b/ecmascript/parser/src/parser/expr.rs @@ -35,7 +35,7 @@ impl<'a, I: Tokens> Parser { pub(super) fn parse_assignment_expr(&mut self) -> PResult> { trace_cur!(self, parse_assignment_expr); - if self.input.syntax().typescript() { + if self.input.syntax().typescript() && self.input.syntax().jsx() { // Note: When the JSX plugin is on, type assertions (` x`) aren't valid // syntax.