Skip to content

Commit

Permalink
Use single quotes in JS code where possible. NFC (#21133)
Browse files Browse the repository at this point in the history
For some reason this actually saves on code size too.
  • Loading branch information
sbc100 committed Jan 23, 2024
1 parent da25bce commit 7e6366d
Show file tree
Hide file tree
Showing 68 changed files with 81 additions and 81 deletions.
6 changes: 3 additions & 3 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -2187,9 +2187,9 @@ addToLibrary({
#endif // ENVIRONMENT_MAY_BE_NODE
// we couldn't find a proper implementation, as Math.random() is not suitable for /dev/random, see emscripten-core/emscripten/pull/7096
#if ASSERTIONS
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 } };");
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 } };');
#else
abort("initRandomDevice");
abort('initRandomDevice');
#endif
},

Expand Down Expand Up @@ -3198,7 +3198,7 @@ addToLibrary({
#endif
}
#if ASSERTIONS && ASYNCIFY != 2 // With JSPI the function stored in the table will be a wrapper.
assert(wasmTable.get(funcPtr) == func, "JavaScript-side Wasm function table mirror is out of date!");
assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!');
#endif
return func;
},
Expand Down
2 changes: 1 addition & 1 deletion src/library_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ addToLibrary({
$FS__postset: function() {
// TODO: do we need noFSInit?
addAtInit(`
if (!Module["noFSInit"] && !FS.init.initialized)
if (!Module['noFSInit'] && !FS.init.initialized)
FS.init();
FS.ignorePermissions = false;
`)
Expand Down
14 changes: 7 additions & 7 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ function assert(condition, text) {
// builds with assertions.
#if !hasExportedSymbol('malloc')
function _malloc() {
abort("malloc() called but not included in the build - add '_malloc' to EXPORTED_FUNCTIONS");
abort('malloc() called but not included in the build - add `_malloc` to EXPORTED_FUNCTIONS');
}
#endif // malloc
#if !hasExportedSymbol('free')
function _free() {
// Show a helpful error since we used to include free by default in the past.
abort("free() called but not included in the build - add '_free' to EXPORTED_FUNCTIONS");
abort('free() called but not included in the build - add `_free` to EXPORTED_FUNCTIONS');
}
#endif // free
#endif // ASSERTIONS
Expand Down Expand Up @@ -641,9 +641,9 @@ function getBinarySync(file) {
return readBinary(file);
}
#if WASM_ASYNC_COMPILATION
throw "both async and sync fetching of the wasm failed";
throw 'both async and sync fetching of the wasm failed';
#else
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)";
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)';
#endif
}
Expand All @@ -666,7 +666,7 @@ function getBinaryPromise(binaryFile) {
) {
return fetch(binaryFile, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}).then((response) => {
if (!response['ok']) {
throw "failed to load wasm binary file at '" + binaryFile + "'";
throw `failed to load wasm binary file at '${binaryFile}'`;
}
return response['arrayBuffer']();
}).catch(() => getBinarySync(binaryFile));
Expand Down Expand Up @@ -982,7 +982,7 @@ function createWasm() {
wasmMemory = wasmExports['memory'];
{{{ receivedSymbol('wasmMemory') }}}
#if ASSERTIONS
assert(wasmMemory, "memory not found in wasm exports");
assert(wasmMemory, 'memory not found in wasm exports');
// This assertion doesn't hold when emscripten is run in --post-link
// mode.
// TODO(sbc): Read INITIAL_MEMORY out of the wasm file in post-link mode.
Expand All @@ -998,7 +998,7 @@ function createWasm() {
wasmTable = wasmExports['__indirect_function_table'];
{{{ receivedSymbol('wasmTable') }}}
#if ASSERTIONS && !PURE_WASI
assert(wasmTable, "table not found in wasm exports");
assert(wasmTable, 'table not found in wasm exports');
#endif

#if AUDIO_WORKLET
Expand Down
10 changes: 5 additions & 5 deletions src/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
if (scriptDirectory.startsWith('blob:')) {
scriptDirectory = '';
} else {
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf('/')+1);
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, '').lastIndexOf('/')+1);
}

#if ENVIRONMENT && ASSERTIONS
Expand Down Expand Up @@ -492,19 +492,19 @@ assert(
#endif // PTHREADS

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

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

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

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

#endif // ASSERTIONS
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_ctors1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24684
24683
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_ctors2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24652
24651
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11016
11015
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
28574
28573
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except_wasm.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9904
9903
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except_wasm.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24577
24576
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_mangle.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
28574
28573
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_noexcept.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24684
24683
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5253
5252
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12140
12139
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_files_js_fs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7875
7874
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_files_js_fs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19706
19705
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_files_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3167
3168
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_files_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6887
6886
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8416
8412
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O0.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23086
23081
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3020
3019
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7787
7782
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2664
2663
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5542
5541
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O3.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5388
5387
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_Os.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5388
5387
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_Oz.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5355
5354
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_dylink.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6486
6485
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_dylink.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14401
14400
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1932
1933
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4174
4173
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5388
5387
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2165
2164
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4670
4669
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4721
4720
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2618
2617
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5569
5568
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3_grow.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5892
5891
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2476
2475
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5285
5284
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3_standalone.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5215
5214
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2186
2187
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4721
4720
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4721
4720
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4721
4720
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_64.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1725
1727
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_64.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3647
3646
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7245
7242
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O0.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19710
19705
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4437
4432
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1661
1663
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3374
3373
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O3.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1619
1621
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O3.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3324
3323
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_Os.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1619
1621
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_Os.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3324
3323
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_Oz-ctors.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1611
1612
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_Oz-ctors.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3309
3308
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_Oz.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1619
1621
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_Oz.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3324
3323
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_pthreads.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13666
13665
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1619
1621
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3324
3323
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
58262
58257
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size_no_asserts.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
31646
31641
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size_strict.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57104
57099
4 changes: 2 additions & 2 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -12087,8 +12087,8 @@ def test_missing_malloc_export(self):
}
''')
self.do_runf('unincluded_malloc.c', (
"malloc() called but not included in the build - add '_malloc' to EXPORTED_FUNCTIONS",
"free() called but not included in the build - add '_free' to EXPORTED_FUNCTIONS"))
'malloc() called but not included in the build - add `_malloc` to EXPORTED_FUNCTIONS',
'free() called but not included in the build - add `_free` to EXPORTED_FUNCTIONS'), assert_all=True)

def test_getrusage(self):
self.do_runf('other/test_getrusage.c')
Expand Down
2 changes: 1 addition & 1 deletion tools/emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ def install_wrapper(sym):
args = ', '.join(args)
wrapper += f"({args}) => ({mangled} = {exported}wasmExports['{name}'])({args});"
else:
wrapper += 'wasmExports["%s"]' % name
wrapper += f"wasmExports['{name}']"

wrappers.append(wrapper)
return wrappers
Expand Down

0 comments on commit 7e6366d

Please sign in to comment.