Skip to content
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: inline needMoreData function, add edge-case tests #21009

Closed
wants to merge 1 commit into from

Conversation

kodemill
Copy link
Contributor

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

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
@nodejs-github-bot nodejs-github-bot added the stream Issues and PRs related to the stream subsystem. label May 29, 2018
@mscdex
Copy link
Contributor

mscdex commented May 29, 2018

Why the runtime code change?

Also, why the code comment change?

@kodemill
Copy link
Contributor Author

I think the comment wasn't reflecting needMoreData's behaviour since the check for state.needReadable was removed in d37e59f.
There is an orphaned PR #19896, where @BridgeAR suggested that this function could be inlined.

@BridgeAR BridgeAR requested review from mcollina and mafintosh May 29, 2018 18:07
@mafintosh
Copy link
Member

Thanks for the comment explanation.

LGTM

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lance
Copy link
Member

lance commented Jun 1, 2018

@mcollina
Copy link
Member

mcollina commented Jun 2, 2018

Landed in 1c07ebf

@mcollina mcollina closed this Jun 2, 2018
mcollina pushed a commit that referenced this pull request Jun 2, 2018
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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Lance Ball <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jun 6, 2018
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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Lance Ball <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Jun 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants