perf(linter): inline is_function_node into run functions#17373
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 #17373 will not alter performanceComparing Summary
Footnotes
|
542b761 to
571e6dc
Compare
120c867 to
d2abc78
Compare
571e6dc to
e188d8c
Compare
There was a problem hiding this comment.
Pull request overview
This PR aims to improve linter performance by 1-2% by inlining the is_function_node helper function directly into the run methods of two rules, allowing the linter codegen to perform better static analysis and optimize node type filtering.
Key changes:
- Inlined function node type checks in
max_nested_callbacksandmax_lines_per_functionrules - Updated generated code to specify
NODE_TYPESbitsets for more efficient node filtering - Removed
is_function_nodeimport from the affected rules
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
crates/oxc_linter/src/rules/eslint/max_nested_callbacks.rs |
Inlined function node checks at the start of run() and removed is_function_node check from is_callback() helper |
crates/oxc_linter/src/rules/eslint/max_lines_per_function.rs |
Inlined function node checks at the start of run() and removed is_function_node import |
crates/oxc_linter/src/generated/rule_runner_impls.rs |
Updated NODE_TYPES to filter for Function and ArrowFunctionExpression types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e188d8c to
23857c2
Compare
Merge activity
|
Inlining the `is_function_node` function allows the linter codegen to do the static analysis more easily. I suppose this is slightly negative towards less maintainability, but I don't expect we'll have more types of functions added to JS anytime soon. And the +1-2% improvement is hard to pass up for being so easy: <img width="723" height="436" alt="image" src="https://github.com/user-attachments/assets/7612c36e-3006-4cea-a038-d0e9b027ee04" />
23857c2 to
eecee5d
Compare

Inlining the
is_function_nodefunction allows the linter codegen to do the static analysis more easily. I suppose this is slightly negative towards less maintainability, but I don't expect we'll have more types of functions added to JS anytime soon. And the +1-2% improvement is hard to pass up for being so easy: