perf(es/parser): Make typescript parser faster (#2483)

swc_ecma_parser:
 - Check for option before backtracking.
This commit is contained in:
Donny/강동윤 2021-10-20 00:00:48 +09:00 committed by GitHub
parent b0361caa58
commit bf886bac73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

2
Cargo.lock generated
View File

@ -2710,7 +2710,7 @@ dependencies = [
[[package]]
name = "swc_ecma_parser"
version = "0.75.0"
version = "0.75.1"
dependencies = [
"either",
"enum_kind",

View File

@ -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

View File

@ -35,7 +35,7 @@ impl<'a, I: Tokens> Parser<I> {
pub(super) fn parse_assignment_expr(&mut self) -> PResult<Box<Expr>> {
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 (`<T> x`) aren't valid
// syntax.