Skip to content

Commit eff3dc0

Browse files
authored
feat: Replace unicode-id crate with unicode-id-start (#78)
We've gone full circle 😅 The `unicode-id` and `unicode-id-start` crates were cloned from (`unicode-xid`)(https://crates.io/crates/unicode-xid) and [`unicode-ident`](https://crates.io/crates/unicode-ident) for usages in the [oxc project](https://github.com/oxc-project/oxc). Oxc will be using this crate for sourcemap support, and is currently using the better optimized `unicode-id-start` crate. I don't want to include two similar dependencies due to the rather large static storage size of these crates. The `unicode-id-start` crate is also faster and uses slightly less static storage. See full details at https://github.com/oxc-project/unicode-id-start/tree/master?tab=readme-ov-file#comparison-of-performance --- The version "1" is used instead of the latest version because the crate is stable, future versions will only include unicode version upgrades.
1 parent 091e8f4 commit eff3dc0

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ all-features = true
2727
url = "2.1.1"
2828
serde = { version = "1.0.104", features = ["derive"] }
2929
serde_json = "1.0.48"
30-
unicode-id = "0.3"
30+
unicode-id-start = "1"
3131
if_chain = "1.0.0"
3232
scroll = { version = "0.10.1", features = ["derive"], optional = true }
3333
data-encoding = "2.3.3"

src/js_identifiers.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
use unicode_id::UnicodeID;
2-
31
/// Returns true if `c` is a valid character for an identifier start.
42
fn is_valid_start(c: char) -> bool {
53
c == '$' || c == '_' || c.is_ascii_alphabetic() || {
64
if c.is_ascii() {
75
false
86
} else {
9-
UnicodeID::is_id_start(c)
7+
unicode_id_start::is_id_start_unicode(c)
108
}
119
}
1210
}
@@ -21,7 +19,7 @@ fn is_valid_continue(c: char) -> bool {
2119
if c.is_ascii() {
2220
false
2321
} else {
24-
UnicodeID::is_id_continue(c)
22+
unicode_id_start::is_id_continue_unicode(c)
2523
}
2624
}
2725
}

0 commit comments

Comments
 (0)