From 8b8affee0732239c81320fc09b19d0cbf33800bf Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 15 Apr 2014 12:57:53 -0700 Subject: stop using __proto__ as an optimization, it actually makes things slower --- src/library_fs.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/library_fs.js') diff --git a/src/library_fs.js b/src/library_fs.js index 3d0036ee..d53210f9 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -394,16 +394,12 @@ mergeInto(LibraryManager.library, { } }); } - if (stream.__proto__) { - // reuse the object - stream.__proto__ = FS.FSStream.prototype; - } else { - var newStream = new FS.FSStream(); - for (var p in stream) { - newStream[p] = stream[p]; - } - stream = newStream; + // clone it, so we can return an instance of FSStream + var newStream = new FS.FSStream(); + for (var p in stream) { + newStream[p] = stream[p]; } + stream = newStream; var fd = FS.nextfd(fd_start, fd_end); stream.fd = fd; FS.streams[fd] = stream; -- cgit v1.2.3-18-g5258