From affce3688f76878a16733ec0b5e4c60ef738d4e4 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 5 Apr 2022 20:59:48 -0700 Subject: [PATCH] Rely on unicode-xid to optimize ASCII properly --- Cargo.toml | 2 +- src/fallback.rs | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 401bfaff..15588962 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ targets = ["x86_64-unknown-linux-gnu"] features = ["span-locations"] [dependencies] -unicode-xid = "0.2" +unicode-xid = "0.2.2" [dev-dependencies] quote = { version = "1.0", default_features = false } diff --git a/src/fallback.rs b/src/fallback.rs index ac5437d3..be53877f 100644 --- a/src/fallback.rs +++ b/src/fallback.rs @@ -666,18 +666,11 @@ impl Ident { } pub(crate) fn is_ident_start(c: char) -> bool { - ('a' <= c && c <= 'z') - || ('A' <= c && c <= 'Z') - || c == '_' - || (c > '\x7f' && UnicodeXID::is_xid_start(c)) + c == '_' || UnicodeXID::is_xid_start(c) } pub(crate) fn is_ident_continue(c: char) -> bool { - ('a' <= c && c <= 'z') - || ('A' <= c && c <= 'Z') - || c == '_' - || ('0' <= c && c <= '9') - || (c > '\x7f' && UnicodeXID::is_xid_continue(c)) + UnicodeXID::is_xid_continue(c) } fn validate_ident(string: &str) {