diff options
| author | Ibraheem Ahmed <ibrah1440@gmail.com> | 2021-07-26 20:17:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-26 20:17:28 -0400 |
| commit | a397fdcc3858a4c6d63f7dd88994d2214ded4482 (patch) | |
| tree | c68b249a809edea617d54ad4b867dac5392c89d7 | |
| parent | 08095fc1f875c89e507f17cf6c6a780c8ffa4c01 (diff) | |
Remove ASCII fast path from rustc_lexer::{is_id_continue, is_id_start}
| -rw-r--r-- | compiler/rustc_lexer/src/lib.rs | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/compiler/rustc_lexer/src/lib.rs b/compiler/rustc_lexer/src/lib.rs index 4cb2a6ca50f..b5e6d256a99 100644 --- a/compiler/rustc_lexer/src/lib.rs +++ b/compiler/rustc_lexer/src/lib.rs @@ -273,24 +273,14 @@ pub fn is_whitespace(c: char) -> bool { /// a formal definition of valid identifier name. pub fn is_id_start(c: char) -> bool { // This is XID_Start OR '_' (which formally is not a XID_Start). - // We also add fast-path for ascii idents - ('a'..='z').contains(&c) - || ('A'..='Z').contains(&c) - || c == '_' - || (c > '\x7f' && unicode_xid::UnicodeXID::is_xid_start(c)) + c == '_' || unicode_xid::UnicodeXID::is_xid_start(c) } /// True if `c` is valid as a non-first character of an identifier. /// See [Rust language reference](https://doc.rust-lang.org/reference/identifiers.html) for /// a formal definition of valid identifier name. pub fn is_id_continue(c: char) -> bool { - // This is exactly XID_Continue. - // We also add fast-path for ascii idents - ('a'..='z').contains(&c) - || ('A'..='Z').contains(&c) - || ('0'..='9').contains(&c) - || c == '_' - || (c > '\x7f' && unicode_xid::UnicodeXID::is_xid_continue(c)) + unicode_xid::UnicodeXID::is_xid_continue(c) } /// The passed string is lexically an identifier. |
