Skip to content

perf(semantic): use cheaper test for source type#18235

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/01-19-perf_semantic_use_cheaper_test_for_source_type
Jan 19, 2026
Merged

perf(semantic): use cheaper test for source type#18235
graphite-app[bot] merged 1 commit intomainfrom
om/01-19-perf_semantic_use_cheaper_test_for_source_type

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Jan 19, 2026

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.

@github-actions github-actions bot added A-semantic Area - Semantic C-performance Category - Solution not expected to change functional behavior, only performance labels Jan 19, 2026
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@overlookmotel overlookmotel marked this pull request as ready for review January 19, 2026 13:05
Copilot AI review requested due to automatic review settings January 19, 2026 13:05
@overlookmotel overlookmotel self-assigned this Jan 19, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.meta is 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.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 19, 2026

Merging this PR will not alter performance

✅ 42 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/01-19-perf_semantic_use_cheaper_test_for_source_type (f69e9a7) with main (645c3f0)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@overlookmotel
Copy link
Member Author

I think uncontroversial change, so merging without review.

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Jan 19, 2026
Copy link
Member Author

overlookmotel commented Jan 19, 2026

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.
@graphite-app graphite-app bot force-pushed the om/01-19-perf_semantic_use_cheaper_test_for_source_type branch from f69e9a7 to 52073d9 Compare January 19, 2026 13:11
@graphite-app graphite-app bot merged commit 52073d9 into main Jan 19, 2026
21 checks passed
@graphite-app graphite-app bot deleted the om/01-19-perf_semantic_use_cheaper_test_for_source_type branch January 19, 2026 13:18
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 19, 2026
overlookmotel added a commit that referenced this pull request Jan 19, 2026
### 🐛 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-semantic Area - Semantic C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants