feat(minifier): evaluate Math.sqrt and Math.cbrt#8731
Merged
graphite-app[bot] merged 1 commit intomainfrom Jan 26, 2025
Merged
Conversation
Member
Author
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. |
5d8ec60 to
82a21ad
Compare
0f7b472 to
9556f95
Compare
Member
Merge activity
|
CodSpeed Performance ReportMerging #8731 will not alter performanceComparing Summary
|
82a21ad to
cbeda1b
Compare
9556f95 to
3378661
Compare
cbeda1b to
672d6e9
Compare
3378661 to
899d108
Compare
672d6e9 to
335d07e
Compare
899d108 to
2f3b1d4
Compare
2f3b1d4 to
ad8ec4a
Compare
ad8ec4a to
dda3b76
Compare
Replaces `Math.sqrt(a)` and `Math.cbrt(a)` when a is a constant and the result is an integer. The motivation of this PR is to add a comment that `Math.sqrt` / `Math.cbrt` cannot be replaced to `**`, rather than the actual minification improvement. **Reference** - [Spec of `Math.sqrt`](https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-math.sqrt) - [Spec of `Math.cbrt`](https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-math.cbrt) - [Spec of `Number::exponentiate`](https://tc39.es/ecma262/multipage/ecmascript-data-types-and-values.html#sec-numeric-types-number-exponentiate)
dda3b76 to
9e32f55
Compare
Boshen
added a commit
that referenced
this pull request
Jan 26, 2025
## [0.48.1] - 2025-01-26 ### Features - b7f13e6 ast: Implement utf8 to utf16 span converter (#8687) (Boshen) - 6589c3b mangler: Reuse variable names (#8562) (翠 / green) - 29bd215 minifier: Minimize `Infinity.toString(radix)` to `'Infinity'` (#8732) (Boshen) - e0117db minifier: Replace `const` with `let` for non-exported read-only variables (#8733) (sapphi-red) - 9e32f55 minifier: Evaluate `Math.sqrt` and `Math.cbrt` (#8731) (sapphi-red) - 360d49e minifier: Replace `Math.pow` with `**` (#8730) (sapphi-red) - 2e9a560 minifier: `NaN.toString(radix)` is always `NaN` (#8727) (Boshen) - cbe0e82 minifier: Minimize `foo(...[])` -> `foo()` (#8726) (Boshen) - e9fb5fe minifier: Dce pure expressions such as `new Map()` (#8725) (Boshen) ### Bug Fixes - 0944758 codegen: Remove parens from `new (import(''), function() {})` (#8707) (Boshen) - 33de70a mangler: Handle cases where a var is declared in a block scope (#8706) (翠 / green) - d982cdb minifier: `Unknown.fromCharCode` should not be treated as `String.fromCharCode` (#8709) (sapphi-red) - e7ab96c transformer/jsx: Incorrect `isStaticChildren` argument for `Fragment` with multiple children (#8713) (Dunqing) - 3e509e1 transformer/typescript: Enum merging when same name declared in outer scope (#8691) (branchseer) ### Performance - dc0b0f2 manger: Remove useless `tmp_bindings` (#8735) (Dunqing) - e472ced mangler: Optimize handling of collecting lived scope ids (#8724) (Dunqing) - 8587965 minifier: Normalize `undefined` to `void 0` before everything else (#8699) (Boshen) ### Refactor - 58002e2 ecmascript: Remove the lifetime annotation on `MayHaveSideEffects` (#8717) (Boshen) - 10e5920 linter: Move finishing default diagnostic message to `GraphicalReporter` (#8683) (Sysix) - 52a37d0 mangler: Simplify initialization of `slots` (#8734) (Dunqing) - 6bc906c minifier: Allow mutating arguments in methods called from `try_fold_known_string_methods` (#8729) (sapphi-red) - bf8be23 minifier: Use `Ctx` (#8716) (Boshen) - 0af0267 minifier: Side effect detection needs symbols resolution (#8715) (Boshen) - 32e0e47 minifier: Clean up `Normalize` (#8700) (Boshen) - c792068 semantic: Simplify `ScopeTree::iter_bindings` (#8723) (Dunqing) ### Testing - 03229c5 minifier: Fix broken tests (#8722) (Boshen) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Replaces
Math.sqrt(a)andMath.cbrt(a)when a is a constant and the result is an integer.The motivation of this PR is to add a comment that
Math.sqrt/Math.cbrtcannot be replaced to**, rather than the actual minification improvement.Reference
Math.sqrtMath.cbrtNumber::exponentiate