-
-
Notifications
You must be signed in to change notification settings - Fork 713
perf(linter): id-length: check if ident is ASCII before segmenting
#14767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf(linter): id-length: check if ident is ASCII before segmenting
#14767
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #14767 will not alter performanceComparing Summary
Footnotes
|
1e5e67e to
949a636
Compare
b42a79f to
86ecae1
Compare
949a636 to
60a9f3d
Compare
Merge activity
|
…14767) Profiling shows that segmenting into graphemes is much slower than just looking at the number of bytes. A simple check on `is_ascii` allows us to avoid splitting into graphemes and use the identifier length instead, which is much faster. We could optimize this further in the future by doing some faster ASCII check, but this is a good start.
60a9f3d to
92b4302
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
…ks (#14821) Previous PR (#14767) implemented an initial ASCII check, but I forgot to add it to the other identifier checks as well. This now adds the fast path ASCII check to all of the branches for this rule. In addition, we no longer need to call `.to_string()` to allocate for each identifier, we can simply do the exceptions check with `&str`. This should greatly benefit large files which have lots of identifiers, but this will pretty much universally improve perf on every file since this rule runs on every identifier and almost every JS file has identifiers. <img width="714" height="535" alt="image" src="https://github.com/user-attachments/assets/f67a43e8-0e91-4f6d-805b-a031f9881c74" />

Profiling shows that segmenting into graphemes is much slower than just looking at the number of bytes. A simple check on
is_asciiallows us to avoid splitting into graphemes and use the identifier length instead, which is much faster. We could optimize this further in the future by doing some faster ASCII check, but this is a good start.