summaryrefslogtreecommitdiff
path: root/lib/_stream_transform.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-04-30 15:09:54 -0700
committerisaacs <i@izs.me>2013-05-14 11:36:04 -0700
commitbdb78b9945f65a0f2a364995eaf099561a902df7 (patch)
treed69cfff70d6e6dfad04037841ae767769d294ba0 /lib/_stream_transform.js
parent0b8af89363f2ee9824376dd5e5fc5a918ea9aeeb (diff)
downloadnode-new-bdb78b9945f65a0f2a364995eaf099561a902df7.tar.gz
stream: don't create unnecessary buffers in Readable
If there is an encoding, and we do 'stream.push(chunk, enc)', and the encoding argument matches the stated encoding, then we're converting from a string, to a buffer, and then back to a string. Of course, this is a completely pointless bit of work, so it's best to avoid it when we know that we can do so safely.
Diffstat (limited to 'lib/_stream_transform.js')
-rw-r--r--lib/_stream_transform.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js
index 8a00d343b6..e925b4bb51 100644
--- a/lib/_stream_transform.js
+++ b/lib/_stream_transform.js
@@ -135,9 +135,9 @@ function Transform(options) {
});
}
-Transform.prototype.push = function(chunk) {
+Transform.prototype.push = function(chunk, encoding) {
this._transformState.needTransform = false;
- return Duplex.prototype.push.call(this, chunk);
+ return Duplex.prototype.push.call(this, chunk, encoding);
};
// This is the part where you do stuff!