-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
refactor(es/minifier): Remove mutated
and mutation_by_call_count
#7890
Conversation
@@ -323,7 +322,7 @@ impl Optimizer<'_> { | |||
&& usage.declared | |||
&& may_remove | |||
&& !usage.reassigned | |||
&& (usage.can_inline_var() || usage.is_mutated_only_by_one_call()) | |||
&& usage.assign_count == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to check if a used only once var is mutated -- we inline it anyway.
pub(crate) fn is_infected(&self) -> bool { | ||
!self.infects_to.is_empty() | ||
} | ||
|
||
pub(crate) fn can_inline_var(&self) -> bool { | ||
!self.mutated || (self.assign_count == 0 && !self.reassigned) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This becomes
!self.mutated() || (self.assign_count == 0 && !self.reassigned)
which is
!(self.assign_count > 0 || self.has_property_mutation) || (self.assign_count == 0 && !self.reassigned)
and thus can be simplified into
usage.assign_count == 0 && (!usage.has_property_mutation || !usage.reassigned)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
swc-bump:
- swc_ecma_usage_analyzer
mutated
and mutation_by_call_count
mutated
and mutation_by_call_count
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated review comment generated by auto-rebase script
**Description:** x-ref: https://vercel.slack.com/archives/C02HY34AKME/p1695334071194139 Reproduction: https://github.com/kdy1/repro-test-mdx-korean Regression of next.js: `v13.4.11`(swc_core@v0.79.13) => `v13.5.2` (swc_core@v0.83.12) - `next@v13.4.19` works (swc_core@v0.79.59) - `next@v13.4.20-canary.3` works (swc_core@v0.79.70) - **`next@v13.4.20-canary.32` fails** (swc_core@v0.83.12) Commit range: 662f236...e67bf05 - `swc_core@v0.79.70`: 662f236 - `swc_core@v0.83.12`: e67bf05 Diff: https://gist.github.com/kdy1/047e7e5537c34180d446cb3d5b95fce8 --- I did more investigation by monkey-patching the `next` package. `.minify()` resolved without an exception. It means that `.minify()` is producing an invalid ES code. So... candidates are - #7890 - #7876 - #7858 - #7856 - #7853 - #7832
Description:
mutated
can be seen as a combination ofreassigned
andhas_property_mutation
, andmutation_by_call_count
is simply useless.