mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-12 07:35:07 +00:00
Add an explicit fast path for whitespace to is_identifier_continuation
(#9532)
This commit is contained in:
parent
2b605527bd
commit
21f2d0c90b
3 changed files with 14 additions and 6 deletions
|
@ -1498,9 +1498,12 @@ fn is_unicode_identifier_start(c: char) -> bool {
|
|||
// Checks if the character c is a valid continuation character as described
|
||||
// in https://docs.python.org/3/reference/lexical_analysis.html#identifiers
|
||||
fn is_identifier_continuation(c: char) -> bool {
|
||||
match c {
|
||||
'a'..='z' | 'A'..='Z' | '_' | '0'..='9' => true,
|
||||
c => is_xid_continue(c),
|
||||
// Arrange things such that ASCII codepoints never
|
||||
// result in the slower `is_xid_continue` getting called.
|
||||
if c.is_ascii() {
|
||||
matches!(c, 'a'..='z' | 'A'..='Z' | '_' | '0'..='9')
|
||||
} else {
|
||||
is_xid_continue(c)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue