Skip to content
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

(es/minifer): number = number * 1 edge case #9935

Open
Le0Developer opened this issue Jan 23, 2025 · 2 comments
Open

(es/minifer): number = number * 1 edge case #9935

Le0Developer opened this issue Jan 23, 2025 · 2 comments
Assignees
Milestone

Comments

@Le0Developer
Copy link

The optimization in #9903 has an edge case where number = number * 1 is converted into number = +number as caught here instead of the shorter number *= 1.

Playground

@kdy1
Copy link
Member

kdy1 commented Jan 23, 2025

Do you have a profiling result of real world gzip being actually larger?

@kdy1 kdy1 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2025
@kdy1 kdy1 reopened this Jan 23, 2025
@Le0Developer
Copy link
Author

Interestingly, gzip is one byte longer with *= 1.
However brotli with *= 1 is 8 bytes smaller:

a.js is using number = +number, b.js has the old behavior of number*=1

-rw-r--r-- 1 leodev staff 119072 Jan 23 15:15 a.js.br
-rw-r--r-- 1 leodev staff 147519 Jan 23 15:15 a.js.gz
-rw-r--r-- 1 leodev staff 119064 Jan 23 15:16 b.js.br
-rw-r--r-- 1 leodev staff 147520 Jan 23 15:16 b.js.gz

Based on https://github.com/Austaras/swc/blob/6c92ae75da433febbfec89333b2211477063f10e/crates/swc_ecma_minifier/tests/projects/output/angular-1.2.5.js

@kdy1 kdy1 modified the milestones: PR will be accepted, Planned Jan 23, 2025
@Austaras Austaras self-assigned this Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants