-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/compat): Optimize
for-of
loops for array literals (#5141)
- Loading branch information
1 parent
1c75c4a
commit 9351303
Showing
98 changed files
with
509 additions
and
2,160 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
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
26 changes: 5 additions & 21 deletions
26
crates/swc/tests/tsc-references/ES3For-ofTypeCheck2_es5.1.normal.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,22 +1,6 @@ | ||
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; | ||
try { | ||
//@target: ES3 | ||
for(var _iterator = [ | ||
true | ||
][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ | ||
var v = _step.value; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally{ | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} finally{ | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
//@target: ES3 | ||
for(var _i = 0, _iter = [ | ||
true | ||
]; _i < _iter.length; _i++){ | ||
var v = _iter[_i]; | ||
} |
17 changes: 3 additions & 14 deletions
17
crates/swc/tests/tsc-references/ES3For-ofTypeCheck2_es5.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,14 +1,3 @@ | ||
var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0; | ||
try { | ||
for(var _step, _iterator = [ | ||
!0 | ||
][Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)_step.value; | ||
} catch (err) { | ||
_didIteratorError = !0, _iteratorError = err; | ||
} finally{ | ||
try { | ||
_iteratorNormalCompletion || null == _iterator.return || _iterator.return(); | ||
} finally{ | ||
if (_didIteratorError) throw _iteratorError; | ||
} | ||
} | ||
for(var _i = 0, _iter = [ | ||
!0 | ||
]; _i < _iter.length; _i++)_iter[_i]; |
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
20 changes: 2 additions & 18 deletions
20
crates/swc/tests/tsc-references/ES5For-of11_es5.1.normal.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,20 +1,4 @@ | ||
var v; | ||
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined; | ||
try { | ||
for(var _iterator = [][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){ | ||
v = _step.value; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally{ | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} finally{ | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
for(var _i = 0, _iter = []; _i < _iter.length; _i++){ | ||
v = _iter[_i]; | ||
} |
13 changes: 1 addition & 12 deletions
13
crates/swc/tests/tsc-references/ES5For-of11_es5.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 @@ | ||
var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0; | ||
try { | ||
for(var _step, _iterator = [][Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)_step.value; | ||
} catch (err) { | ||
_didIteratorError = !0, _iteratorError = err; | ||
} finally{ | ||
try { | ||
_iteratorNormalCompletion || null == _iterator.return || _iterator.return(); | ||
} finally{ | ||
if (_didIteratorError) throw _iteratorError; | ||
} | ||
} | ||
for(var _i = 0, _iter = []; _i < _iter.length; _i++)_iter[_i]; |
Oops, something went wrong.
9351303
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/minify/libraries/antd
1692834637
ns/iter (± 28232071
)1932032371
ns/iter (± 27192327
)0.88
es/full/minify/libraries/d3
434876642
ns/iter (± 16346928
)447705610
ns/iter (± 10775886
)0.97
es/full/minify/libraries/echarts
1675929606
ns/iter (± 80176562
)1972100392
ns/iter (± 25516323
)0.85
es/full/minify/libraries/jquery
102595523
ns/iter (± 8045764
)103848392
ns/iter (± 1391029
)0.99
es/full/minify/libraries/lodash
129134314
ns/iter (± 5050254
)138684407
ns/iter (± 1729480
)0.93
es/full/minify/libraries/moment
56974278
ns/iter (± 3327854
)61331634
ns/iter (± 192921
)0.93
es/full/minify/libraries/react
18828576
ns/iter (± 1674478
)21054237
ns/iter (± 13633336
)0.89
es/full/minify/libraries/terser
622170330
ns/iter (± 13861041
)721144174
ns/iter (± 16149487
)0.86
es/full/minify/libraries/three
566832630
ns/iter (± 15499364
)604773354
ns/iter (± 12285036
)0.94
es/full/minify/libraries/typescript
3644547289
ns/iter (± 79482883
)4072868709
ns/iter (± 44530182
)0.89
es/full/minify/libraries/victory
747365605
ns/iter (± 15940155
)838225191
ns/iter (± 13568734
)0.89
es/full/minify/libraries/vue
148821065
ns/iter (± 4366435
)157963025
ns/iter (± 3826967
)0.94
es/full/codegen/es3
30332
ns/iter (± 1752
)38538
ns/iter (± 919
)0.79
es/full/codegen/es5
30437
ns/iter (± 402
)39238
ns/iter (± 851
)0.78
es/full/codegen/es2015
30419
ns/iter (± 722
)38858
ns/iter (± 1249
)0.78
es/full/codegen/es2016
30334
ns/iter (± 542
)38738
ns/iter (± 1404
)0.78
es/full/codegen/es2017
30328
ns/iter (± 554
)38630
ns/iter (± 332
)0.79
es/full/codegen/es2018
30365
ns/iter (± 723
)38599
ns/iter (± 574
)0.79
es/full/codegen/es2019
30407
ns/iter (± 1483
)38801
ns/iter (± 978
)0.78
es/full/codegen/es2020
30386
ns/iter (± 479
)38504
ns/iter (± 2797
)0.79
es/full/all/es3
203588748
ns/iter (± 16146744
)225461943
ns/iter (± 4838514
)0.90
es/full/all/es5
181863659
ns/iter (± 11757281
)210626771
ns/iter (± 3070735
)0.86
es/full/all/es2015
155594035
ns/iter (± 10152569
)172908102
ns/iter (± 3799454
)0.90
es/full/all/es2016
146948390
ns/iter (± 8979916
)170967796
ns/iter (± 3569695
)0.86
es/full/all/es2017
152711643
ns/iter (± 8449788
)170988796
ns/iter (± 3002209
)0.89
es/full/all/es2018
157806354
ns/iter (± 13117980
)169002354
ns/iter (± 3348946
)0.93
es/full/all/es2019
156866314
ns/iter (± 8584001
)167171714
ns/iter (± 4138836
)0.94
es/full/all/es2020
150693099
ns/iter (± 6051814
)161487168
ns/iter (± 4402476
)0.93
es/full/parser
710211
ns/iter (± 39199
)868360
ns/iter (± 39428
)0.82
es/full/base/fixer
30043
ns/iter (± 549
)36594
ns/iter (± 1211
)0.82
es/full/base/resolver_and_hygiene
87804
ns/iter (± 2894
)110092
ns/iter (± 3991
)0.80
serialization of ast node
206
ns/iter (± 3
)262
ns/iter (± 7
)0.79
serialization of serde
222
ns/iter (± 2
)274
ns/iter (± 3
)0.81
This comment was automatically generated by workflow using github-action-benchmark.