Skip to content

feat(minifier): do not flip if/else when it would produce longer result#17556

Merged
Boshen merged 3 commits intooxc-project:mainfrom
armano2:feat/minifier-do-not-flip-if-statements
Jan 15, 2026
Merged

feat(minifier): do not flip if/else when it would produce longer result#17556
Boshen merged 3 commits intooxc-project:mainfrom
armano2:feat/minifier-do-not-flip-if-statements

Conversation

@armano2
Copy link
Contributor

@armano2 armano2 commented Jan 1, 2026

Disable flipping of negated if statement when alternate is if statement

when if else if is encountered, flipping always produces at-least one extra character (in many cases 5) as new consequent has to be wrapped in {}, this also prevents remove_dead_code and minimize_statements to be run to covert if statement's to ternary expression

@github-actions github-actions bot added A-minifier Area - Minifier C-enhancement Category - New feature or request labels Jan 1, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 1, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing armano2:feat/minifier-do-not-flip-if-statements (c50251c) with main (78fa1ba)

Summary

✅ 38 untouched benchmarks
⏩ 7 skipped benchmarks1

Footnotes

  1. 7 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.

@armano2 armano2 marked this pull request as ready for review January 1, 2026 14:00
@armano2
Copy link
Contributor Author

armano2 commented Jan 14, 2026

i'm not sure why ast changed after last merge, but that seem to be an issue on main, just ast

@Boshen Boshen merged commit d1016b9 into oxc-project:main Jan 15, 2026
26 of 27 checks passed
@armano2 armano2 deleted the feat/minifier-do-not-flip-if-statements branch January 15, 2026 11:20
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