Skip to content

Conversation

sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Sep 20, 2025

Compress

var a = foo, b = a;

into

var b = foo;

refs #13912

@github-actions github-actions bot added A-minifier Area - Minifier C-enhancement Category - New feature or request labels Sep 20, 2025
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.

Copy link

codspeed-hq bot commented Sep 20, 2025

CodSpeed Instrumentation Performance Report

Merging #13959 will not alter performance

Comparing 09-20-feat_minifier_inline_single_use_variables_within_the_same_variable_declarations (c0cb248) with main (6fcb0d0)

Summary

✅ 37 untouched

@sapphi-red sapphi-red force-pushed the 09-20-feat_minifier_inline_single_use_variables_within_the_same_variable_declarations branch from a2f9787 to c0cb248 Compare September 20, 2025 15:49
@sapphi-red sapphi-red marked this pull request as ready for review September 20, 2025 15:54
@Copilot Copilot AI review requested due to automatic review settings September 20, 2025 15:54
Copy link
Contributor

@Copilot 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

Adds a peephole optimization to inline single-use variables within the same variable declaration list (e.g., var a = foo, b = a; -> var b = foo;), and refactors internal logic to support reuse across contexts.

  • Implement inline-within-declaration optimization and invoke it for standalone var/let/const declarations and for-loop init declarations
  • Extract shared logic for substituting single-use symbols from a list of declarators
  • Update tests and snapshots to reflect improved minification and allocation/sizing deltas

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tasks/track_memory_allocations/allocs_minifier.snap Updates memory allocation snapshots reflecting new optimization effects.
tasks/minsize/minsize.snap Updates size metrics snapshots showing slightly improved minification.
crates/oxc_minifier/tests/peephole/inline_single_use_variable.rs Adds tests covering inlining within the same variable declarations, including for-loop init and using/let cases.
crates/oxc_minifier/src/peephole/minimize_statements.rs Implements the inlining within declaration lists, refactors substitution logic into a reusable helper, and wires calls at appropriate transformation points.
crates/oxc_minifier/src/peephole/minimize_conditions.rs Adjusts a test to expect additional constant folding/elimination due to the new optimization.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-minifier Area - Minifier C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants