Skip to content

Commit 7e6366d

Browse files
authored
Use single quotes in JS code where possible. NFC (#21133)
For some reason this actually saves on code size too.
1 parent da25bce commit 7e6366d

File tree

68 files changed

+81
-81
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+81
-81
lines changed

src/library.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,9 +2187,9 @@ addToLibrary({
21872187
#endif // ENVIRONMENT_MAY_BE_NODE
21882188
// we couldn't find a proper implementation, as Math.random() is not suitable for /dev/random, see emscripten-core/emscripten/pull/7096
21892189
#if ASSERTIONS
2190-
abort("no cryptographic support found for randomDevice. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: (array) => { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };");
2190+
abort('no cryptographic support found for randomDevice. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: (array) => { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };');
21912191
#else
2192-
abort("initRandomDevice");
2192+
abort('initRandomDevice');
21932193
#endif
21942194
},
21952195

@@ -3198,7 +3198,7 @@ addToLibrary({
31983198
#endif
31993199
}
32003200
#if ASSERTIONS && ASYNCIFY != 2 // With JSPI the function stored in the table will be a wrapper.
3201-
assert(wasmTable.get(funcPtr) == func, "JavaScript-side Wasm function table mirror is out of date!");
3201+
assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!');
32023202
#endif
32033203
return func;
32043204
},

src/library_fs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ addToLibrary({
3737
$FS__postset: function() {
3838
// TODO: do we need noFSInit?
3939
addAtInit(`
40-
if (!Module["noFSInit"] && !FS.init.initialized)
40+
if (!Module['noFSInit'] && !FS.init.initialized)
4141
FS.init();
4242
FS.ignorePermissions = false;
4343
`)

src/preamble.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ function assert(condition, text) {
9595
// builds with assertions.
9696
#if !hasExportedSymbol('malloc')
9797
function _malloc() {
98-
abort("malloc() called but not included in the build - add '_malloc' to EXPORTED_FUNCTIONS");
98+
abort('malloc() called but not included in the build - add `_malloc` to EXPORTED_FUNCTIONS');
9999
}
100100
#endif // malloc
101101
#if !hasExportedSymbol('free')
102102
function _free() {
103103
// Show a helpful error since we used to include free by default in the past.
104-
abort("free() called but not included in the build - add '_free' to EXPORTED_FUNCTIONS");
104+
abort('free() called but not included in the build - add `_free` to EXPORTED_FUNCTIONS');
105105
}
106106
#endif // free
107107
#endif // ASSERTIONS
@@ -641,9 +641,9 @@ function getBinarySync(file) {
641641
return readBinary(file);
642642
}
643643
#if WASM_ASYNC_COMPILATION
644-
throw "both async and sync fetching of the wasm failed";
644+
throw 'both async and sync fetching of the wasm failed';
645645
#else
646-
throw "sync fetching of the wasm failed: you can preload it to Module['wasmBinary'] manually, or emcc.py will do that for you when generating HTML (but not JS)";
646+
throw 'sync fetching of the wasm failed: you can preload it to Module["wasmBinary"] manually, or emcc.py will do that for you when generating HTML (but not JS)';
647647
#endif
648648
}
649649

@@ -666,7 +666,7 @@ function getBinaryPromise(binaryFile) {
666666
) {
667667
return fetch(binaryFile, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}).then((response) => {
668668
if (!response['ok']) {
669-
throw "failed to load wasm binary file at '" + binaryFile + "'";
669+
throw `failed to load wasm binary file at '${binaryFile}'`;
670670
}
671671
return response['arrayBuffer']();
672672
}).catch(() => getBinarySync(binaryFile));
@@ -982,7 +982,7 @@ function createWasm() {
982982
wasmMemory = wasmExports['memory'];
983983
{{{ receivedSymbol('wasmMemory') }}}
984984
#if ASSERTIONS
985-
assert(wasmMemory, "memory not found in wasm exports");
985+
assert(wasmMemory, 'memory not found in wasm exports');
986986
// This assertion doesn't hold when emscripten is run in --post-link
987987
// mode.
988988
// TODO(sbc): Read INITIAL_MEMORY out of the wasm file in post-link mode.
@@ -998,7 +998,7 @@ function createWasm() {
998998
wasmTable = wasmExports['__indirect_function_table'];
999999
{{{ receivedSymbol('wasmTable') }}}
10001000
#if ASSERTIONS && !PURE_WASI
1001-
assert(wasmTable, "table not found in wasm exports");
1001+
assert(wasmTable, 'table not found in wasm exports');
10021002
#endif
10031003

10041004
#if AUDIO_WORKLET

src/shell.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
382382
if (scriptDirectory.startsWith('blob:')) {
383383
scriptDirectory = '';
384384
} else {
385-
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf('/')+1);
385+
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, '').lastIndexOf('/')+1);
386386
}
387387

388388
#if ENVIRONMENT && ASSERTIONS
@@ -492,19 +492,19 @@ assert(
492492
#endif // PTHREADS
493493

494494
#if !ENVIRONMENT_MAY_BE_WEB
495-
assert(!ENVIRONMENT_IS_WEB, "web environment detected but not enabled at build time. Add 'web' to `-sENVIRONMENT` to enable.");
495+
assert(!ENVIRONMENT_IS_WEB, 'web environment detected but not enabled at build time. Add `web` to `-sENVIRONMENT` to enable.');
496496
#endif
497497

498498
#if !ENVIRONMENT_MAY_BE_WORKER
499-
assert(!ENVIRONMENT_IS_WORKER, "worker environment detected but not enabled at build time. Add 'worker' to `-sENVIRONMENT` to enable.");
499+
assert(!ENVIRONMENT_IS_WORKER, 'worker environment detected but not enabled at build time. Add `worker` to `-sENVIRONMENT` to enable.');
500500
#endif
501501

502502
#if !ENVIRONMENT_MAY_BE_NODE
503-
assert(!ENVIRONMENT_IS_NODE, "node environment detected but not enabled at build time. Add 'node' to `-sENVIRONMENT` to enable.");
503+
assert(!ENVIRONMENT_IS_NODE, 'node environment detected but not enabled at build time. Add `node` to `-sENVIRONMENT` to enable.');
504504
#endif
505505

506506
#if !ENVIRONMENT_MAY_BE_SHELL
507-
assert(!ENVIRONMENT_IS_SHELL, "shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable.");
507+
assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.');
508508
#endif
509509

510510
#endif // ASSERTIONS
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24684
1+
24683
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24652
1+
24651
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11016
1+
11015
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
28574
1+
28573
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9904
1+
9903
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24577
1+
24576
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
28574
1+
28573
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24684
1+
24683
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5253
1+
5252
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12140
1+
12139
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7875
1+
7874
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19706
1+
19705
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3167
1+
3168
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6887
1+
6886
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8416
1+
8412
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
23086
1+
23081
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3020
1+
3019
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7787
1+
7782
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2664
1+
2663
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5542
1+
5541
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5388
1+
5387
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5388
1+
5387
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5355
1+
5354
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6486
1+
6485
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14401
1+
14400
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1932
1+
1933
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4174
1+
4173
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5388
1+
5387
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2165
1+
2164
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4670
1+
4669
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4721
1+
4720
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2618
1+
2617
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5569
1+
5568
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5892
1+
5891
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2476
1+
2475
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5285
1+
5284
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5215
1+
5214
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2186
1+
2187
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4721
1+
4720
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4721
1+
4720
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4721
1+
4720
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1725
1+
1727
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3647
1+
3646
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7245
1+
7242
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19710
1+
19705
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4437
1+
4432
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1661
1+
1663
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3374
1+
3373
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1619
1+
1621
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3324
1+
3323
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1619
1+
1621
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3324
1+
3323
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1611
1+
1612
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3309
1+
3308
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1619
1+
1621
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3324
1+
3323
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
13666
1+
13665
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1619
1+
1621
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3324
1+
3323
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
58262
1+
58257
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
31646
1+
31641
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
57104
1+
57099

test/test_other.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12087,8 +12087,8 @@ def test_missing_malloc_export(self):
1208712087
}
1208812088
''')
1208912089
self.do_runf('unincluded_malloc.c', (
12090-
"malloc() called but not included in the build - add '_malloc' to EXPORTED_FUNCTIONS",
12091-
"free() called but not included in the build - add '_free' to EXPORTED_FUNCTIONS"))
12090+
'malloc() called but not included in the build - add `_malloc` to EXPORTED_FUNCTIONS',
12091+
'free() called but not included in the build - add `_free` to EXPORTED_FUNCTIONS'), assert_all=True)
1209212092

1209312093
def test_getrusage(self):
1209412094
self.do_runf('other/test_getrusage.c')

tools/emscripten.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ def install_wrapper(sym):
803803
args = ', '.join(args)
804804
wrapper += f"({args}) => ({mangled} = {exported}wasmExports['{name}'])({args});"
805805
else:
806-
wrapper += 'wasmExports["%s"]' % name
806+
wrapper += f"wasmExports['{name}']"
807807

808808
wrappers.append(wrapper)
809809
return wrappers

0 commit comments

Comments
 (0)