diff options
author | Gil Pedersen <git@gpost.dk> | 2013-02-14 20:26:54 +0100 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-02-15 18:51:22 -0800 |
commit | 0a9930a230cf7fe8e2f7d431fc85a7f21517d39b (patch) | |
tree | 858963429300b47b7b1262aef19e2aacf11be0e2 /lib | |
parent | 8476aefc8e21fb8db597937c7e8fbc3490a72f39 (diff) | |
download | node-new-0a9930a230cf7fe8e2f7d431fc85a7f21517d39b.tar.gz |
stream: Pipe data in chunks matching read data
This creates better flow for large values of lowWaterMark.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_stream_readable.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 825042baa5..333a3a015d 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -137,8 +137,13 @@ function howMuchToRead(n, state) { if (state.objectMode) return n === 0 ? 0 : 1; - if (isNaN(n) || n === null) - return state.length; + if (isNaN(n) || n === null) { + // only flow one buffer at a time + if (state.flowing && state.buffer.length) + return state.buffer[0].length; + else + return state.length; + } if (n <= 0) return 0; |