Skip to content

Commit a26a1da

Browse files
committed
Elide findWasmBinary in -sSINGLE_FILE mode. NFC
1 parent 1baef43 commit a26a1da

File tree

82 files changed

+93
-85
lines changed

Some content is hidden

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

82 files changed

+93
-85
lines changed

src/preamble.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,13 @@ function instrumentWasmTableWithAbort() {
603603
}
604604
#endif
605605

606+
#if SINGLE_FILE
607+
// In SINGLE_FILE mode the wasm binary is encoded inline here as a data: URL.
608+
var wasmBinaryFile ??= '{{{ WASM_BINARY_FILE }}}';
609+
#else
610+
var wasmBinaryFile;
606611
function findWasmBinary() {
607-
#if EXPORT_ES6 && USE_ES6_IMPORT_META && !SINGLE_FILE && !AUDIO_WORKLET
612+
#if EXPORT_ES6 && USE_ES6_IMPORT_META && !AUDIO_WORKLET
608613
if (Module['locateFile']) {
609614
#endif
610615
var f = '{{{ WASM_BINARY_FILE }}}';
@@ -614,7 +619,7 @@ function findWasmBinary() {
614619
}
615620
#endif
616621
return f;
617-
#if EXPORT_ES6 && USE_ES6_IMPORT_META && !SINGLE_FILE && !AUDIO_WORKLET // In single-file mode, repeating WASM_BINARY_FILE would emit the contents again. For an Audio Worklet, we cannot use `new URL()`.
622+
#if EXPORT_ES6 && USE_ES6_IMPORT_META && !AUDIO_WORKLET // In single-file mode, repeating WASM_BINARY_FILE would emit the contents again. For an Audio Worklet, we cannot use `new URL()`.
618623
}
619624
#if ENVIRONMENT_MAY_BE_SHELL
620625
if (ENVIRONMENT_IS_SHELL)
@@ -624,8 +629,9 @@ function findWasmBinary() {
624629
return new URL('{{{ WASM_BINARY_FILE }}}', import.meta.url).href;
625630
#endif
626631
}
632+
#endif
633+
627634

628-
var wasmBinaryFile;
629635

630636
function getBinarySync(file) {
631637
if (file == wasmBinaryFile && wasmBinary) {
@@ -1079,7 +1085,9 @@ function getWasmImports() {
10791085
}
10801086
#endif
10811087

1082-
wasmBinaryFile ??= findWasmBinary();
1088+
#if !SINGLE_FILE
1089+
wasmBinaryFile = findWasmBinary();
1090+
#endif
10831091

10841092
#if WASM_ASYNC_COMPILATION
10851093
#if RUNTIME_DEBUG
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8542
1+
8540
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20925
1+
20923
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8526
1+
8525
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20893
1+
20891
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9572
1+
9571
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24770
1+
24768
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8503
1+
8502
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20819
1+
20817
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8503
1+
8502

0 commit comments

Comments
 (0)