Remove ASCII fast path from rustc_lexer::{is_id_continue, is_id_start}
This commit is contained in:
parent
08095fc1f8
commit
a397fdcc38
1 changed files with 2 additions and 12 deletions
|
@ -273,24 +273,14 @@ pub fn is_whitespace(c: char) -> bool {
|
||||||
/// a formal definition of valid identifier name.
|
/// a formal definition of valid identifier name.
|
||||||
pub fn is_id_start(c: char) -> bool {
|
pub fn is_id_start(c: char) -> bool {
|
||||||
// This is XID_Start OR '_' (which formally is not a XID_Start).
|
// This is XID_Start OR '_' (which formally is not a XID_Start).
|
||||||
// We also add fast-path for ascii idents
|
c == '_' || unicode_xid::UnicodeXID::is_xid_start(c)
|
||||||
('a'..='z').contains(&c)
|
|
||||||
|| ('A'..='Z').contains(&c)
|
|
||||||
|| c == '_'
|
|
||||||
|| (c > '\x7f' && unicode_xid::UnicodeXID::is_xid_start(c))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// True if `c` is valid as a non-first character of an identifier.
|
/// 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
|
/// See [Rust language reference](https://doc.rust-lang.org/reference/identifiers.html) for
|
||||||
/// a formal definition of valid identifier name.
|
/// a formal definition of valid identifier name.
|
||||||
pub fn is_id_continue(c: char) -> bool {
|
pub fn is_id_continue(c: char) -> bool {
|
||||||
// This is exactly XID_Continue.
|
unicode_xid::UnicodeXID::is_xid_continue(c)
|
||||||
// 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))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The passed string is lexically an identifier.
|
/// The passed string is lexically an identifier.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue