Created
February 1, 2013 00:19
-
-
Save isaacs/4688017 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js | |
index 630a3f3..de7d4e3 100644 | |
--- a/lib/_stream_readable.js | |
+++ b/lib/_stream_readable.js | |
@@ -107,7 +107,18 @@ function Readable(options) { | |
// write() some more. | |
Readable.prototype.push = function(chunk) { | |
var rs = this._readableState; | |
- rs.onread(null, chunk); | |
+ | |
+ if (rs.flowing && rs.length === 0 && | |
+ chunk !== null && chunk !== undefined && | |
+ (rs.objectMode || chunk.length)) { | |
+ // console.error('R pushPipe optimization'); | |
+ pipeWrite(this, rs, chunk); | |
+ if (rs.awaitDrain <= 0) { | |
+ pipeAfterWrite(this, rs); | |
+ } | |
+ } else { | |
+ rs.onread(null, chunk); | |
+ } | |
// if it's past the high water mark, we can push in some more. | |
// Also, if it's still within the lowWaterMark, we can stand some |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment