diff options
author | isaacs <i@izs.me> | 2013-03-03 19:14:06 -0800 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-03-05 14:27:15 -0800 |
commit | 426b4c625802c7b6913fa09237aa9745bf3ae84a (patch) | |
tree | 81756bcb6720145decb01160df08b5315784657b /lib/fs.js | |
parent | cd68d86c3283af2f4b3c349c2081c609e3978b9b (diff) | |
download | nodejs-426b4c625802c7b6913fa09237aa9745bf3ae84a.tar.gz nodejs-426b4c625802c7b6913fa09237aa9745bf3ae84a.tar.bz2 nodejs-426b4c625802c7b6913fa09237aa9745bf3ae84a.zip |
stream: _write takes an encoding argument
This vastly reduces the overhead of decodeStrings:false streams,
such as net and http.
Diffstat (limited to 'lib/fs.js')
-rw-r--r-- | lib/fs.js | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1650,12 +1650,14 @@ WriteStream.prototype.open = function() { }; -WriteStream.prototype._write = function(data, cb) { +WriteStream.prototype._write = function(data, encoding, cb) { if (!Buffer.isBuffer(data)) return this.emit('error', new Error('Invalid data')); if (typeof this.fd !== 'number') - return this.once('open', this._write.bind(this, data, cb)); + return this.once('open', function() { + this._write(data, encoding, cb); + }); var self = this; fs.write(this.fd, data, 0, data.length, this.pos, function(er, bytes) { |