perf(linter/import/extensions): skip empty config and borrow extensions#24075
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes the import/extensions linter rule hot path by avoiding unnecessary work when the rule has no effective configuration, and by reducing allocations when parsing written extensions.
Changes:
- Add an early return in
process_importwhen config is effectively empty/default (no rules to enforce). - Change written-extension parsing to return
Cow<str>so lowercase extensions can stay borrowed instead of allocating. - Minor refactor of query-string stripping in extension parsing (
split_once('?')).
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Merging this PR will not alter performance
Comparing Footnotes
|
Merge activity
|
…ns (#24075) ## Summary - split out the remaining safe `import/extensions` performance slice from #23829 for easier review and bisectability - skip the rule work early when the config is effectively empty/default and there is nothing to enforce - parse written extensions as `Cow<str>` so common lowercase specifiers stay borrowed - preserve the existing written-extension behavior for cases like written `.js` resolving to `.ts` Credit to Yagiz Nizipli for the original work in #23829. Co-authored-by: Yagiz Nizipli <yagiz@nizipli.com>
d969992 to
b1be114
Compare
…ns (#24075) ## Summary - split out the remaining safe `import/extensions` performance slice from #23829 for easier review and bisectability - skip the rule work early when the config is effectively empty/default and there is nothing to enforce - parse written extensions as `Cow<str>` so common lowercase specifiers stay borrowed - preserve the existing written-extension behavior for cases like written `.js` resolving to `.ts` Credit to Yagiz Nizipli for the original work in #23829. Co-authored-by: Yagiz Nizipli <yagiz@nizipli.com>
…ns (#24075) ## Summary - split out the remaining safe `import/extensions` performance slice from #23829 for easier review and bisectability - skip the rule work early when the config is effectively empty/default and there is nothing to enforce - parse written extensions as `Cow<str>` so common lowercase specifiers stay borrowed - preserve the existing written-extension behavior for cases like written `.js` resolving to `.ts` Credit to Yagiz Nizipli for the original work in #23829. Co-authored-by: Yagiz Nizipli <yagiz@nizipli.com>
Summary
import/extensionsperformance slice from perf(linter): speed up hot rules on large codebases #23829 for easier review and bisectabilityCow<str>so common lowercase specifiers stay borrowed.jsresolving to.tsCredit to Yagiz Nizipli for the original work in #23829.
Co-authored-by: Yagiz Nizipli yagiz@nizipli.com