feat(minifier): fold (!0).toString() to true#12938
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request enhances the JavaScript minifier to optimize boolean expressions followed by .toString() calls, specifically folding expressions like (!0).toString() to the string literal 'true'. The change improves minifier performance by evaluating constant expressions at compile time.
- Extends constant evaluation to handle boolean expressions in
.toString()calls - Adds test coverage for the new optimization patterns
- Refactors the toString evaluation logic to be more generic
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_minifier/src/peephole/replace_known_methods.rs | Adds test cases for (!0).toString() and (!1).toString() optimizations |
| crates/oxc_ecmascript/src/constant_evaluation/value.rs | Adds is_null() helper method for null value checking |
| crates/oxc_ecmascript/src/constant_evaluation/call_expr.rs | Refactors toString evaluation to use generic constant evaluation with null/undefined filtering |
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 Instrumentation Performance ReportMerging #12938 will not alter performanceComparing Summary
Footnotes |
Merge activity
|
cb34649 to
784796d
Compare

No description provided.