Skip to content

Commit 6f780ca

Browse files
authoredApr 1, 2024··
perf(es/parser): Use faster unicode crate (#8785)
1 parent 25d6092 commit 6f780ca

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed
 

‎Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/swc_ecma_ast/Cargo.toml

+4-5
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,17 @@ bitflags = "2.3.2"
3535
bytecheck = { version = "0.6.10", optional = true }
3636
is-macro = "0.3.0"
3737
num-bigint = { version = "0.4", features = ["serde"] }
38+
phf = { version = "0.11.2", features = ["macros"] }
3839
rkyv = { package = "rkyv", version = "=0.7.42", optional = true, features = [
3940
"strict",
4041
"validation",
4142
] }
4243
scoped-tls = "1.0.1"
4344
serde = { version = "1.0.133", features = ["derive"], optional = true }
44-
unicode-id = "0.3"
45-
4645
string_enum = { version = "0.4.2", path = "../string_enum" }
47-
swc_atoms = { version = "0.6.5", path = "../swc_atoms" }
48-
swc_common = { version = "0.33.20", path = "../swc_common" }
49-
phf = { version = "0.11.2", features = ["macros"] }
46+
swc_atoms = { version = "0.6.5", path = "../swc_atoms" }
47+
swc_common = { version = "0.33.20", path = "../swc_common" }
48+
unicode-id-start = "1.1.2"
5049

5150
[dev-dependencies]
5251
serde_json = "1"

‎crates/swc_ecma_ast/src/ident.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use swc_atoms::{js_word, Atom};
99
use swc_common::{
1010
ast_node, util::take::Take, BytePos, EqIgnoreSpan, Span, Spanned, SyntaxContext, DUMMY_SP,
1111
};
12-
use unicode_id::UnicodeID;
1312

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

@@ -230,7 +229,7 @@ impl Ident {
230229
return ASCII_START.0[c as usize];
231230
}
232231

233-
UnicodeID::is_id_start(c)
232+
unicode_id_start::is_id_start_unicode(c)
234233
}
235234

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

253-
UnicodeID::is_id_continue(c) || c == '\u{200c}' || c == '\u{200d}'
252+
unicode_id_start::is_id_continue_unicode(c)
254253
}
255254

256255
/// Alternative for `toIdentifier` of babel.

0 commit comments

Comments
 (0)
Please sign in to comment.