-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
code cleanup #19896
code cleanup #19896
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,8 +311,7 @@ function chunkInvalid(state, chunk) { | |
// 'readable' event will be triggered. | ||
function needMoreData(state) { | ||
return !state.ended && | ||
(state.length < state.highWaterMark || | ||
state.length === 0); | ||
(state.length < state.highWaterMark); | ||
} | ||
|
||
Readable.prototype.isPaused = function() { | ||
|
@@ -434,7 +433,7 @@ Readable.prototype.read = function(n) { | |
debug('need readable', doRead); | ||
|
||
// if we currently have less than the highWaterMark, then also read some | ||
if (state.length === 0 || state.length - n < state.highWaterMark) { | ||
if (state.length - n < state.highWaterMark) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please note that I suggest that this change would be with another PR because code cleaning shouldn't change code logic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch @MoonBall |
||
doRead = true; | ||
debug('length less than watermark', doRead); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: this function could be inlined. It only has a single call site.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also needs to be
<=
as aboveThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with
<=
, a test case is failingAssertionError [ERR_ASSERTION]: true strictEqual false at Object.<anonymous> (node/test/parallel/test-stream2-objects.js:212:12)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, this is ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove the parenthesis? They are not needed anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can prob also be a one liner as this looks like it's <80 chars
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. I will do that