-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stream: simplify checks for highWaterMark #19893
Comments
So line lib/_streams_readable.js#314 and line lib/_streams_readable.js#437 needs to be replaced. Removing |
@mcollina If no one is already working on this, I would like to volunteer. First-time node contributor. |
@sagirk I have started working on the issue |
i also have started to work on it |
Inline the needMoreData function since it has only one call place. Update the related comment. Add a test for the edge case where HWM=0 and state.length=0. Add a test for ReadableStream.read(n) method's edge case where n, HWM and state.length are all zero. This proves that there is no easy way to simplify the check at https://github.com/nodejs/node/blob/master/lib/_stream_readable.js#L440 Fixes: nodejs#19893 Refs: nodejs#19896
@mcollina @vishal7201 I made some progress on this, since it looked like it was orphaned. |
Inline the needMoreData function since it has only one call place. Update the related comment. Add a test for the edge case where HWM=0 and state.length=0. Add a test for ReadableStream.read(n) method's edge case where n, HWM and state.length are all zero. This proves that there is no easy way to simplify the check at https://github.com/nodejs/node/blob/master/lib/_stream_readable.js#L440 Fixes: #19893 Refs: #19896 PR-URL: #21009 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Lance Ball <lball@redhat.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
In
lib/_streams_readable.js
, we have a block of code like this:Because
state.highWaterMark
could be< 0
ornull
orundefined
or really any object in Node < 10. However, we landed #18098 and so now we can simplify all those checks to bestate.length <= state.highWaterMark
.The text was updated successfully, but these errors were encountered: