Skip to content

Commit 57054fc

Browse files
sbc100hedwigz
authored andcommitted
Simplify asyncLoad. NFC (emscripten-core#23100)
Turns out non of the callers were relying the adding of the run dependencies here. There are 4 call sites total: - emscripten_async_wget_data: Explicitly sets noRunDep - emscripten_wget_data: Explicitly sets noRunDep - loadDynamicLibrary: The outer loadDylibs already has an explicit calls to addRunDependency/removeRunDependency. - FS_createPreloadedFile: Already has an explicit calls to addRunDependency/removeRunDependency.
1 parent ae49149 commit 57054fc

File tree

5 files changed

+5
-9
lines changed

5 files changed

+5
-9
lines changed

src/library.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,18 +2194,14 @@ addToLibrary({
21942194
return x.startsWith('dynCall_') ? x : '_' + x;
21952195
},
21962196

2197-
$asyncLoad__docs: '/** @param {boolean=} noRunDep */',
2198-
$asyncLoad: (url, noRunDep) => {
2197+
$asyncLoad: (url) => {
21992198
return new Promise((resolve, reject) => {
2200-
var dep = !noRunDep ? getUniqueRunDependency(`al ${url}`) : '';
2201-
if (dep) addRunDependency(dep);
22022199
readAsync(url).then(
22032200
(arrayBuffer) => {
22042201
#if ASSERTIONS
22052202
assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
22062203
#endif
22072204
resolve(new Uint8Array(arrayBuffer));
2208-
if (dep) removeRunDependency(dep);
22092205
}, reject);
22102206
});
22112207
},

src/library_async.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ addToLibrary({
471471
emscripten_wget_data: (url, pbuffer, pnum, perror) => {
472472
return Asyncify.handleSleep((wakeUp) => {
473473
/* no need for run dependency, this is async but will not do any prepare etc. step */
474-
asyncLoad(UTF8ToString(url), /*noRunDep=*/true).then((byteArray) => {
474+
asyncLoad(UTF8ToString(url)).then((byteArray) => {
475475
// can only allocate the buffer after the wakeUp, not during an asyncing
476476
var buffer = _malloc(byteArray.length); // must be freed by caller!
477477
HEAPU8.set(byteArray, buffer);

src/library_wget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ var LibraryWget = {
6565
emscripten_async_wget_data: (url, userdata, onload, onerror) => {
6666
{{{ runtimeKeepalivePush() }}}
6767
/* no need for run dependency, this is async but will not do any prepare etc. step */
68-
asyncLoad(UTF8ToString(url), /*noRunDep=*/true).then((byteArray) => {
68+
asyncLoad(UTF8ToString(url)).then((byteArray) => {
6969
{{{ runtimeKeepalivePop() }}}
7070
callUserCallback(() => {
7171
var buffer = _malloc(byteArray.length);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6294
1+
6276
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
13863
1+
13831

0 commit comments

Comments
 (0)