Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(es/minifier): Support more statements in seqential inliner (#6248)
**Description:** We now inline into the discriminant of a switch statement and into the initializer of for/for-in/for-of statements.
- Loading branch information
Showing
25 changed files
with
675 additions
and
750 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
//// [for-of24.ts] | ||
var x; | ||
for (var v of x); | ||
for (var v of void 0); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
//// [for-of29.ts] | ||
var iterableWithOptionalIterator; | ||
for (var v of iterableWithOptionalIterator); | ||
for (var v of void 0); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
//// [for-of37.ts] | ||
var map = new Map([ | ||
for (var v of new Map([ | ||
[ | ||
"", | ||
!0 | ||
] | ||
]); | ||
for (var v of map); | ||
])); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
//// [for-of38.ts] | ||
var map = new Map([ | ||
for (var [k, v] of new Map([ | ||
[ | ||
"", | ||
!0 | ||
] | ||
]); | ||
for (var [k, v] of map); | ||
])); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
//// [for-of40.ts] | ||
var map = new Map([ | ||
for (var [k = "", v = !1] of new Map([ | ||
[ | ||
"", | ||
!0 | ||
] | ||
]); | ||
for (var [k = "", v = !1] of map); | ||
])); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
//// [for-of45.ts] | ||
var k, v, map = new Map([ | ||
var k, v; | ||
for ([k = "", v = !1] of new Map([ | ||
[ | ||
"", | ||
!0 | ||
] | ||
]); | ||
for ([k = "", v = !1] of map); | ||
])); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
//// [for-of46.ts] | ||
var k, v, map = new Map([ | ||
var k, v; | ||
for ([k = !1, v = ""] of new Map([ | ||
[ | ||
"", | ||
!0 | ||
] | ||
]); | ||
for ([k = !1, v = ""] of map); | ||
])); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
//// [for-of49.ts] | ||
var k, v, map = new Map([ | ||
var k, v; | ||
for ([k, ...[v]] of new Map([ | ||
[ | ||
"", | ||
!0 | ||
] | ||
]); | ||
for ([k, ...[v]] of map); | ||
])); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
//// [for-of50.ts] | ||
var map = new Map([ | ||
for (const [k, v] of new Map([ | ||
[ | ||
"", | ||
!0 | ||
] | ||
]); | ||
for (const [k, v] of map); | ||
])); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
//// [for-of57.ts] | ||
var iter; | ||
for (let num of iter); | ||
for (let num of void 0); |
This file contains 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
10 changes: 2 additions & 8 deletions
10
crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03.2.minified.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,6 @@ | ||
//// [stringLiteralsWithSwitchStatements03.ts] | ||
var x, z; | ||
switch(x){ | ||
var z; | ||
switch(void 0){ | ||
case randBool() ? "foo" : "baz": | ||
case randBool(), "bar": | ||
case "bar": | ||
case "baz": | ||
case "foo": | ||
case "bar": | ||
case z || "baz": | ||
case "baz": | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
86e265a
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.
Benchmark
es/full/bugs-1
387271
ns/iter (± 44005
)413795
ns/iter (± 20077
)0.94
es/full/minify/libraries/antd
1919425798
ns/iter (± 69578682
)2013578744
ns/iter (± 45413342
)0.95
es/full/minify/libraries/d3
439895874
ns/iter (± 9446188
)390547845
ns/iter (± 31387493
)1.13
es/full/minify/libraries/echarts
1623574929
ns/iter (± 86070476
)1704129352
ns/iter (± 31177238
)0.95
es/full/minify/libraries/jquery
116698378
ns/iter (± 2073008
)114639845
ns/iter (± 2082991
)1.02
es/full/minify/libraries/lodash
130046915
ns/iter (± 7912521
)141321460
ns/iter (± 3149692
)0.92
es/full/minify/libraries/moment
67110690
ns/iter (± 3357764
)124155576
ns/iter (± 29574186
)0.54
es/full/minify/libraries/react
22592359
ns/iter (± 1594457
)25326873
ns/iter (± 2992753
)0.89
es/full/minify/libraries/terser
342963771
ns/iter (± 18168980
)312746776
ns/iter (± 9812501
)1.10
es/full/minify/libraries/three
544570838
ns/iter (± 18009687
)532482669
ns/iter (± 26915749
)1.02
es/full/minify/libraries/typescript
3392895098
ns/iter (± 61855995
)3790116593
ns/iter (± 81660888
)0.90
es/full/minify/libraries/victory
836893368
ns/iter (± 32989528
)782618271
ns/iter (± 59720608
)1.07
es/full/minify/libraries/vue
159378942
ns/iter (± 6815178
)172810089
ns/iter (± 3431816
)0.92
es/full/codegen/es3
34252
ns/iter (± 1631
)39429
ns/iter (± 2789
)0.87
es/full/codegen/es5
34251
ns/iter (± 2242
)40071
ns/iter (± 2865
)0.85
es/full/codegen/es2015
33984
ns/iter (± 855
)38257
ns/iter (± 2807
)0.89
es/full/codegen/es2016
33691
ns/iter (± 1486
)39066
ns/iter (± 1348
)0.86
es/full/codegen/es2017
33807
ns/iter (± 2128
)38540
ns/iter (± 1958
)0.88
es/full/codegen/es2018
33949
ns/iter (± 1012
)38611
ns/iter (± 1797
)0.88
es/full/codegen/es2019
34066
ns/iter (± 701
)39887
ns/iter (± 2290
)0.85
es/full/codegen/es2020
34042
ns/iter (± 502
)38580
ns/iter (± 1494
)0.88
es/full/all/es3
201231846
ns/iter (± 10537410
)222064422
ns/iter (± 5598935
)0.91
es/full/all/es5
181233095
ns/iter (± 19041028
)211399283
ns/iter (± 7327180
)0.86
es/full/all/es2015
146046126
ns/iter (± 5716949
)170894992
ns/iter (± 8554800
)0.85
es/full/all/es2016
154544399
ns/iter (± 15929619
)169573948
ns/iter (± 6334468
)0.91
es/full/all/es2017
153665769
ns/iter (± 12731676
)168610335
ns/iter (± 13425787
)0.91
es/full/all/es2018
146092101
ns/iter (± 10370831
)165343930
ns/iter (± 6897689
)0.88
es/full/all/es2019
138399647
ns/iter (± 5247802
)164164489
ns/iter (± 5571963
)0.84
es/full/all/es2020
134339039
ns/iter (± 5818882
)158988979
ns/iter (± 6146350
)0.84
es/full/parser
705046
ns/iter (± 30302
)805844
ns/iter (± 38088
)0.87
es/full/base/fixer
25879
ns/iter (± 976
)29050
ns/iter (± 1785
)0.89
es/full/base/resolver_and_hygiene
90517
ns/iter (± 8647
)104876
ns/iter (± 7312
)0.86
serialization of ast node
212
ns/iter (± 7
)255
ns/iter (± 18
)0.83
serialization of serde
218
ns/iter (± 3
)245
ns/iter (± 14
)0.89
This comment was automatically generated by workflow using github-action-benchmark.