Skip to content

Commit ca93e46

Browse files
authored
Use JS arrow functions in postamble_minimal.js. NFC (#19494)
This leads to a little codesize win in all outputs!
1 parent fd9b486 commit ca93e46

27 files changed

+63
-63
lines changed

emscripten.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -796,9 +796,9 @@ def create_receiving(exports):
796796
# In Wasm exports are assigned inside a function to variables
797797
# existing in top level JS scope, i.e.
798798
# var _main;
799-
# WebAssembly.instantiate(Module["wasm"], imports).then((function(output) {
800-
# var asm = output.instance.exports;
801-
# _main = asm["_main"];
799+
# WebAssembly.instantiate(Module["wasm"], imports).then((output) => {
800+
# var asm = output.instance.exports;
801+
# _main = asm["_main"];
802802
generate_dyncall_assignment = settings.DYNCALLS and '$dynCall' in settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE
803803
exports_that_are_not_initializers = [x for x in exports if x != building.WASM_CALL_CTORS]
804804

src/postamble_minimal.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ if (!WebAssembly.instantiateStreaming && !Module['wasm']) throw 'Must load WebAs
125125
#endif
126126
(WebAssembly.instantiateStreaming
127127
? WebAssembly.instantiateStreaming(fetch('{{{ TARGET_BASENAME }}}.wasm'), imports)
128-
: WebAssembly.instantiate(Module['wasm'], imports)).then(function(output) {
128+
: WebAssembly.instantiate(Module['wasm'], imports)).then((output) => {
129129
#else
130-
WebAssembly.instantiateStreaming(fetch('{{{ TARGET_BASENAME }}}.wasm'), imports).then(function(output) {
130+
WebAssembly.instantiateStreaming(fetch('{{{ TARGET_BASENAME }}}.wasm'), imports).then((output) => {
131131
#endif
132132

133133
#else // Non-streaming instantiation
@@ -137,7 +137,7 @@ WebAssembly.instantiateStreaming(fetch('{{{ TARGET_BASENAME }}}.wasm'), imports)
137137
if (!Module['wasm']) throw 'Must load WebAssembly Module in to variable Module.wasm before adding compiled output .js script to the DOM';
138138
#endif
139139

140-
WebAssembly.instantiate(Module['wasm'], imports).then(function(output) {
140+
WebAssembly.instantiate(Module['wasm'], imports).then((output) => {
141141
#endif
142142

143143
#if !LibraryManager.has('library_exports.js') && !EMBIND
@@ -237,7 +237,7 @@ WebAssembly.instantiate(Module['wasm'], imports).then(function(output) {
237237
}
238238

239239
#if ASSERTIONS || WASM == 2
240-
, function(error) {
240+
, (error) => {
241241
#if ASSERTIONS
242242
console.error(error);
243243
#endif

src/preamble_minimal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
{{{
88
// Helper function to export a symbol on the module object
99
// if requested.
10-
global.maybeExport = function(x) {
10+
global.maybeExport = (x) => {
1111
return MODULARIZE && EXPORT_ALL ? `Module['${x}'] = ` : '';
1212
};
1313
// Export to the AudioWorkletGlobalScope the needed variables to access
1414
// the heap. AudioWorkletGlobalScope is unable to access global JS vars
1515
// in the compiled main JS file.
16-
global.maybeExportIfAudioWorklet = function(x) {
16+
global.maybeExportIfAudioWorklet = (x) => {
1717
return (MODULARIZE && EXPORT_ALL) || AUDIO_WORKLET ? `Module['${x}'] = ` : '';
1818
};
1919
null;

test/code_size/hello_wasm_worker_wasm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ WebAssembly.instantiate(b.wasm, {
4545
},
4646
a: e
4747
}
48-
}).then((function(a) {
48+
}).then((a => {
4949
a = a.instance.exports;
5050
p = a.g;
5151
q = a.i;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.html": 737,
33
"a.html.gz": 433,
4-
"a.js": 715,
4+
"a.js": 707,
55
"a.js.gz": 465,
66
"a.wasm": 1862,
77
"a.wasm.gz": 1040,
8-
"total": 3314,
8+
"total": 3306,
99
"total_gz": 1938
1010
}

test/code_size/hello_webgl2_wasm.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.html": 569,
33
"a.html.gz": 379,
4-
"a.js": 4971,
5-
"a.js.gz": 2430,
4+
"a.js": 4963,
5+
"a.js.gz": 2432,
66
"a.wasm": 10482,
77
"a.wasm.gz": 6707,
8-
"total": 16022,
9-
"total_gz": 9516
8+
"total": 16014,
9+
"total_gz": 9518
1010
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.html": 567,
33
"a.html.gz": 379,
4-
"a.js": 18252,
5-
"a.js.gz": 8055,
4+
"a.js": 18244,
5+
"a.js.gz": 8057,
66
"a.mem": 3171,
77
"a.mem.gz": 2713,
8-
"total": 21990,
9-
"total_gz": 11147
8+
"total": 21982,
9+
"total_gz": 11149
1010
}

test/code_size/hello_webgl_wasm.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.html": 569,
33
"a.html.gz": 379,
4-
"a.js": 4450,
5-
"a.js.gz": 2250,
4+
"a.js": 4442,
5+
"a.js.gz": 2252,
66
"a.wasm": 10482,
77
"a.wasm.gz": 6707,
8-
"total": 15501,
9-
"total_gz": 9336
8+
"total": 15493,
9+
"total_gz": 9338
1010
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.html": 567,
33
"a.html.gz": 379,
4-
"a.js": 17724,
5-
"a.js.gz": 7870,
4+
"a.js": 17716,
5+
"a.js.gz": 7871,
66
"a.mem": 3171,
77
"a.mem.gz": 2713,
8-
"total": 21462,
9-
"total_gz": 10962
8+
"total": 21454,
9+
"total_gz": 10963
1010
}

test/code_size/hello_world_wasm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ WebAssembly.instantiate(d.wasm, {
1111
k.call(c, a);
1212
}
1313
}
14-
}).then((function(a) {
14+
}).then((a => {
1515
a = a.instance.exports;
1616
h = a.d;
1717
f = a.b;

0 commit comments

Comments
 (0)