-
-
Notifications
You must be signed in to change notification settings - Fork 721
feat(minifier): inline single-use variable past read-only variables #14184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(minifier): inline single-use variable past read-only variables #14184
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 Instrumentation Performance ReportMerging #14184 will degrade performances by 8.35%Comparing Summary
Benchmarks breakdown
Footnotes
|
4f18d55 to
ddc6456
Compare
50a938a to
9e5b0b9
Compare
There was a problem hiding this 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 implements an optimization to inline single-use variables past read-only variables in the JavaScript minifier. The change allows variables to be inlined even when they appear after other read-only variables in the declaration order, as long as the variables being moved past are not mutated.
- Adds logic to detect read-only variables that can be safely reordered during inlining
- Includes comprehensive test cases covering various scenarios with read-only and mutable variables
- Updates existing tests to fix compatibility issues with the new optimization
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tasks/track_memory_allocations/allocs_minifier.snap | Updated memory allocation metrics showing improved efficiency |
| tasks/minsize/minsize.snap | Updated file size metrics showing reduced minified output sizes |
| crates/oxc_minifier/tests/peephole/inline_single_use_variable.rs | Added comprehensive test cases for the new read-only variable inlining optimization |
| crates/oxc_minifier/tests/peephole/esbuild.rs | Commented out failing tests and adjusted existing test case to maintain compatibility |
| crates/oxc_minifier/src/peephole/minimize_statements.rs | Implemented core logic to check for read-only variables and allow inlining past them |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Merge activity
|
9e5b0b9 to
6123684
Compare

fixes #13912
As long as we know the variable is not re-assigned, the value is same even if we reordered the expression.
By using that fact, we can compress
to
.