aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-10-28 11:42:54 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-10-28 11:42:54 -0700
commit1844811464c9cfb71bc315e24c61707414db88e6 (patch)
treea817c32f3006005bd468cfbf6c22e7c558d4eba4 /src
parent84272ebefa19a65ccb55a853a81e0a87adf9f213 (diff)
reuse some FS errors in places where overhead is high and stack importance is low
Diffstat (limited to 'src')
-rw-r--r--src/library_fs.js6
-rw-r--r--src/library_memfs.js2
2 files changed, 7 insertions, 1 deletions
diff --git a/src/library_fs.js b/src/library_fs.js
index bd1522a8..90f5d3b0 100644
--- a/src/library_fs.js
+++ b/src/library_fs.js
@@ -28,6 +28,7 @@ mergeInto(LibraryManager.library, {
ignorePermissions: true,
ErrnoError: null, // set during init
+ genericErrors: {},
handleFSError: function(e) {
if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
@@ -1079,6 +1080,11 @@ mergeInto(LibraryManager.library, {
};
FS.ErrnoError.prototype = new Error();
FS.ErrnoError.prototype.constructor = FS.ErrnoError;
+ // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
+ [ERRNO_CODES.ENOENT].forEach(function(code) {
+ FS.genericErrors[code] = new FS.ErrnoError(code);
+ FS.genericErrors[code].stack = '<generic error, no stack>';
+ });
},
staticInit: function() {
FS.ensureErrnoError();
diff --git a/src/library_memfs.js b/src/library_memfs.js
index 94fd767e..51a8da16 100644
--- a/src/library_memfs.js
+++ b/src/library_memfs.js
@@ -117,7 +117,7 @@ mergeInto(LibraryManager.library, {
}
},
lookup: function(parent, name) {
- throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
+ throw FS.genericErrors[ERRNO_CODES.ENOENT];
},
mknod: function(parent, name, mode, dev) {
return MEMFS.createNode(parent, name, mode, dev);