perf(semantic): use cheaper test for source type#18235
perf(semantic): use cheaper test for source type#18235graphite-app[bot] merged 1 commit intomainfrom
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. |
There was a problem hiding this comment.
Pull request overview
This PR optimizes a conditional check in the semantic checker by replacing source_type.is_script() || source_type.is_commonjs() with the logically equivalent but more efficient !source_type.is_module().
Changes:
- Simplified the condition for checking if
import.metais disallowed by using a single negated check instead of two positive checks with OR logic
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merging this PR will not alter performance
Comparing Footnotes
|
|
I think uncontroversial change, so merging without review. |
Merge activity
|
Tiny optimization. Replace `source_type.is_script() || source_type.is_commonjs()` with `!source_type.is_module()`. This is marginally cheaper, and is a bit shorter.
f69e9a7 to
52073d9
Compare
### 🐛 Bug Fixes - f1e2dc0 semantic: No error in `check_function_redeclaration` for CommonJS files (#18231) (overlookmotel) - 645c3f0 transformer: Use `require` not `import` in CommonJS files (#18226) (overlookmotel) - ee9f6a4 mangler: Use `retain` instead of `truncate` to remove empty frequency slots (#18225) (Dunqing) ### ⚡ Performance - 52073d9 semantic: Use cheaper test for source type (#18235) (overlookmotel) Co-authored-by: overlookmotel <[email protected]>

Tiny optimization. Replace
source_type.is_script() || source_type.is_commonjs()with!source_type.is_module(). This is marginally cheaper, and is a bit shorter.