Skip to content

Commit 1d20033

Browse files
authored
Assume node.contents is a TypedArray in emscripten_run_preload_plugins. NFC (#26411)
Since #26398 it should be guaranteed to be.
1 parent f7179e4 commit 1d20033

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/lib/libbrowser.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,14 @@ var LibraryBrowser = {
568568
var _file = UTF8ToString(file);
569569
var data = FS.analyzePath(_file);
570570
if (!data.exists) return -1;
571+
// Here we assume data.object.contents is a TypedArray.
572+
#if ASSERTIONS
573+
assert(data.object.contents.subarray, 'unexpected file content')
574+
#endif
571575
FS.createPreloadedFile(
572576
PATH.dirname(_file),
573577
PATH.basename(_file),
574-
// TODO: This copy is not needed if the contents are already a Uint8Array,
575-
// which they often are (and always are in WasmFS).
576-
new Uint8Array(data.object.contents), true, true,
578+
data.object.contents, /*canRead=*/true, /*canWrite=*/true,
577579
() => {
578580
{{{ runtimeKeepalivePop() }}}
579581
if (onload) {{{ makeDynCall('vp', 'onload') }}}(file);
@@ -582,7 +584,7 @@ var LibraryBrowser = {
582584
{{{ runtimeKeepalivePop() }}}
583585
if (onerror) {{{ makeDynCall('vp', 'onerror') }}}(file);
584586
},
585-
true // don'tCreateFile - it's already there
587+
/*dontCreateFile=*/true // it's already there
586588
);
587589
return 0;
588590
},

test/codesize/test_codesize_hello_dylink_all.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"a.out.js": 244478,
2+
"a.out.js": 244462,
33
"a.out.nodebug.wasm": 577692,
4-
"total": 822170,
4+
"total": 822154,
55
"sent": [
66
"IMG_Init",
77
"IMG_Load",

0 commit comments

Comments
 (0)