summaryrefslogtreecommitdiff
path: root/lib/fs.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-03-03 19:14:06 -0800
committerisaacs <i@izs.me>2013-03-05 14:27:15 -0800
commit426b4c625802c7b6913fa09237aa9745bf3ae84a (patch)
tree81756bcb6720145decb01160df08b5315784657b /lib/fs.js
parentcd68d86c3283af2f4b3c349c2081c609e3978b9b (diff)
downloadnodejs-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.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/fs.js b/lib/fs.js
index d467c5e0c..39a34abc9 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -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) {