Skip to content

feat(minifier): fold (!0).toString() to true#12938

Merged
graphite-app[bot] merged 1 commit intomainfrom
08-09-feat_minifier_fold_0_.tostring_to_false_
Aug 9, 2025
Merged

feat(minifier): fold (!0).toString() to true#12938
graphite-app[bot] merged 1 commit intomainfrom
08-09-feat_minifier_fold_0_.tostring_to_false_

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Aug 9, 2025

No description provided.

Copilot AI review requested due to automatic review settings August 9, 2025 14:26
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 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

@github-actions github-actions bot added A-minifier Area - Minifier C-enhancement Category - New feature or request labels Aug 9, 2025
Copy link
Member Author

Boshen commented Aug 9, 2025


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.

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 9, 2025

CodSpeed Instrumentation Performance Report

Merging #12938 will not alter performance

Comparing 08-09-feat_minifier_fold_0_.tostring_to_false_ (784796d) with main (4f31b73)1

Summary

✅ 34 untouched benchmarks

Footnotes

  1. No successful run was found on main (a13b3ee) during the generation of this report, so 4f31b73 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Aug 9, 2025
Copy link
Member Author

Boshen commented Aug 9, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the 08-09-feat_minifier_fold_0_.tostring_to_false_ branch from cb34649 to 784796d Compare August 9, 2025 14:46
@graphite-app graphite-app bot merged commit 784796d into main Aug 9, 2025
29 checks passed
@graphite-app graphite-app bot deleted the 08-09-feat_minifier_fold_0_.tostring_to_false_ branch August 9, 2025 14:51
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 9, 2025
taearls pushed a commit to taearls/oxc that referenced this pull request Aug 12, 2025
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