diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-10-28 16:21:08 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-28 16:21:08 -0700 |
commit | 34ebaf94125130376d44bc7c3e5cebd11c7a08c5 (patch) | |
tree | 1d60b3cea9ac024fd0f9aed8b53e52ca5fe487ff /src/library_fs.js | |
parent | b405ba1b1337b03be2804354b9ef26aac9d98728 (diff) |
optimize createStream
Diffstat (limited to 'src/library_fs.js')
-rw-r--r-- | src/library_fs.js | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/library_fs.js b/src/library_fs.js index 0e16343a..aece2664 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -360,24 +360,28 @@ mergeInto(LibraryManager.library, { // object isn't directly passed in. not possible until // SOCKFS is completed. createStream: function(stream, fd_start, fd_end) { + if (!FS.FSStream) { + FS.FSStream = {}; + // compatibility + Object.defineProperties(FS.FSStream, { + object: { + get: function() { return this.node; }, + set: function(val) { this.node = val; } + }, + isRead: { + get: function() { return (this.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_WRONLY') }}}; } + }, + isWrite: { + get: function() { return (this.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_RDONLY') }}}; } + }, + isAppend: { + get: function() { return (this.flags & {{{ cDefine('O_APPEND') }}}); } + } + }); + } + stream.prototype = FS.FSStream; var fd = FS.nextfd(fd_start, fd_end); stream.fd = fd; - // compatibility - Object.defineProperties(stream, { - object: { - get: function() { return stream.node; }, - set: function(val) { stream.node = val; } - }, - isRead: { - get: function() { return (stream.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_WRONLY') }}}; } - }, - isWrite: { - get: function() { return (stream.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_RDONLY') }}}; } - }, - isAppend: { - get: function() { return (stream.flags & {{{ cDefine('O_APPEND') }}}); } - } - }); FS.streams[fd] = stream; return stream; }, |