Skip to content

Commit

Permalink
Elide findWasmBinary in -sSINGLE_FILE mode. NFC (emscripten-core#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 authored Dec 17, 2024
1 parent b8254ef commit 3ffc9a0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,13 @@ function instrumentWasmTableWithAbort() {
}
#endif

#if SINGLE_FILE
// In SINGLE_FILE mode the wasm binary is encoded inline here as a data: URL.
var wasmBinaryFile = '{{{ WASM_BINARY_FILE }}}';
#else
var wasmBinaryFile;
function findWasmBinary() {
#if EXPORT_ES6 && USE_ES6_IMPORT_META && !SINGLE_FILE && !AUDIO_WORKLET
#if EXPORT_ES6 && USE_ES6_IMPORT_META && !AUDIO_WORKLET
if (Module['locateFile']) {
#endif
var f = '{{{ WASM_BINARY_FILE }}}';
Expand All @@ -614,7 +619,7 @@ function findWasmBinary() {
}
#endif
return f;
#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()`.
#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()`.
}
#if ENVIRONMENT_MAY_BE_SHELL
if (ENVIRONMENT_IS_SHELL)
Expand All @@ -624,8 +629,7 @@ function findWasmBinary() {
return new URL('{{{ WASM_BINARY_FILE }}}', import.meta.url).href;
#endif
}

var wasmBinaryFile;
#endif

function getBinarySync(file) {
if (file == wasmBinaryFile && wasmBinary) {
Expand Down Expand Up @@ -1079,7 +1083,9 @@ function getWasmImports() {
}
#endif

#if !SINGLE_FILE
wasmBinaryFile ??= findWasmBinary();
#endif

#if WASM_ASYNC_COMPILATION
#if RUNTIME_DEBUG
Expand Down

0 comments on commit 3ffc9a0

Please sign in to comment.