Skip to content

Commit f443aad

Browse files
sbc100uysalibov
authored andcommitted
Remove FS.genericErrors. NFC (emscripten-core#22914)
This system was introduced in 2013 (see 1844811) but never more widely adopted.
1 parent d8e83bb commit f443aad

20 files changed

+32
-26
lines changed

src/library_fs.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ FS.staticInit();
6363
trackingDelegate: {},
6464
#endif
6565
ErrnoError: null, // set during init
66-
genericErrors: {},
6766
filesystems: null,
6867
syncFSRequests: 0, // we warn if there are multiple in flight at once
6968
#if expectToReceiveOnModule('logReadFiles')
@@ -1435,12 +1434,6 @@ FS.staticInit();
14351434
#endif
14361435
},
14371436
staticInit() {
1438-
// Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
1439-
[{{{ cDefs.ENOENT }}}].forEach((code) => {
1440-
FS.genericErrors[code] = new FS.ErrnoError(code);
1441-
FS.genericErrors[code].stack = '<generic error, no stack>';
1442-
});
1443-
14441437
FS.nameTable = new Array(4096);
14451438

14461439
FS.mount(MEMFS, {}, '/');

src/library_memfs.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66

77
addToLibrary({
88
$MEMFS__deps: ['$FS', '$mmapAlloc'],
9+
#if !ASSERTIONS
10+
$MEMFS__postset: `
11+
// This error may happen quite a bit. To avoid overhead we reuse it (and
12+
// suffer a lack of stack info).
13+
MEMFS.doesNotExistError = new FS.ErrnoError({{{ cDefs.ENOENT }}});
14+
/** @suppress {checkTypes} */
15+
MEMFS.doesNotExistError.stack = '<generic error, no stack>';
16+
`,
17+
#endif
918
$MEMFS: {
1019
ops_table: null,
1120
mount(mount) {
@@ -173,7 +182,11 @@ addToLibrary({
173182
}
174183
},
175184
lookup(parent, name) {
176-
throw FS.genericErrors[{{{ cDefs.ENOENT }}}];
185+
#if ASSERTIONS
186+
throw new FS.ErrnoError({{{ cDefs.ENOENT }}});
187+
#else
188+
throw MEMFS.doesNotExistError;
189+
#endif
177190
},
178191
mknod(parent, name, mode, dev) {
179192
return MEMFS.createNode(parent, name, mode, dev);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8465
1+
8447
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20821
1+
20791
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8449
1+
8432
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20789
1+
20759
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9487
1+
9474
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24665
1+
24634
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8427
1+
8414
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20715
1+
20685

0 commit comments

Comments
 (0)