Skip to content

Commit

Permalink
perf(es/parser): Use faster unicode crate (#8785)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Apr 1, 2024
1 parent 25d6092 commit 6f780ca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions crates/swc_ecma_ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,17 @@ bitflags = "2.3.2"
bytecheck = { version = "0.6.10", optional = true }
is-macro = "0.3.0"
num-bigint = { version = "0.4", features = ["serde"] }
phf = { version = "0.11.2", features = ["macros"] }
rkyv = { package = "rkyv", version = "=0.7.42", optional = true, features = [
"strict",
"validation",
] }
scoped-tls = "1.0.1"
serde = { version = "1.0.133", features = ["derive"], optional = true }
unicode-id = "0.3"

string_enum = { version = "0.4.2", path = "../string_enum" }
swc_atoms = { version = "0.6.5", path = "../swc_atoms" }
swc_common = { version = "0.33.20", path = "../swc_common" }
phf = { version = "0.11.2", features = ["macros"] }
swc_atoms = { version = "0.6.5", path = "../swc_atoms" }
swc_common = { version = "0.33.20", path = "../swc_common" }
unicode-id-start = "1.1.2"

[dev-dependencies]
serde_json = "1"
5 changes: 2 additions & 3 deletions crates/swc_ecma_ast/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use swc_atoms::{js_word, Atom};
use swc_common::{
ast_node, util::take::Take, BytePos, EqIgnoreSpan, Span, Spanned, SyntaxContext, DUMMY_SP,
};
use unicode_id::UnicodeID;

use crate::{typescript::TsTypeAnn, Expr};

Expand Down Expand Up @@ -230,7 +229,7 @@ impl Ident {
return ASCII_START.0[c as usize];
}

UnicodeID::is_id_start(c)
unicode_id_start::is_id_start_unicode(c)
}

/// Returns true if `c` is a valid character for an identifier part after
Expand All @@ -250,7 +249,7 @@ impl Ident {
return ASCII_CONTINUE.0[c as usize];
}

UnicodeID::is_id_continue(c) || c == '\u{200c}' || c == '\u{200d}'
unicode_id_start::is_id_continue_unicode(c)
}

/// Alternative for `toIdentifier` of babel.
Expand Down

0 comments on commit 6f780ca

Please sign in to comment.