diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-08-09 22:35:54 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-08-09 08:16:58 +0200 |
commit | f9b7714b4b3f04cba10c4d8b32dad48a68988799 (patch) | |
tree | 23c8183f7ca55214e651ff252ef50abfc80bced4 /lib/net.js | |
parent | f548433195ba08e77ba93640382f474c17a13ecf (diff) | |
download | node-new-f9b7714b4b3f04cba10c4d8b32dad48a68988799.tar.gz |
src: don't call v8::Object::SetHiddenValue()
Don't use v8::Object::SetHiddenValue() to keep a reference alive to the
buffer, we can just as easily do that from JS land and it's a lot faster
to boot.
Because the buffer is now a visible property of the write request
object, it's essential that we do *not* log it - we'd be effectively
serializing the whole buffer to a pretty-printed string.
Diffstat (limited to 'lib/net.js')
-rw-r--r-- | lib/net.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/net.js b/lib/net.js index 6748f0d2de..bac7e47ece 100644 --- a/lib/net.js +++ b/lib/net.js @@ -640,7 +640,13 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) { // Retain chunks if (err === 0) req._chunks = chunks; } else { - var enc = util.isBuffer(data) ? 'buffer' : encoding; + var enc; + if (util.isBuffer(data)) { + req.buffer = data; // Keep reference alive. + enc = 'buffer'; + } else { + enc = encoding; + } err = createWriteReq(req, this._handle, data, enc); } @@ -743,7 +749,7 @@ function afterWrite(status, handle, req) { var self = handle.owner; var state = self._writableState; if (self !== process.stderr && self !== process.stdout) - debug('afterWrite', status, req); + debug('afterWrite', status); // callback may come after call to destroy. if (self.destroyed) { |