-
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
stream: remove unreachable code #18239
Conversation
To avoid a function call `BufferList.prototype.concat()` is not called when there is only a buffer in the list. That buffer is instead accessed directly.
The `n` argument of `BufferList.prototype.concat()` is not the number of `Buffer` instances in the list, but their total length when concatenated.
It's better to modify |
ok. I agree. |
/cc @nodejs/streams |
I'm not super comfortable with this change. |
Do you mean if |
Can you restore the test then? |
|
||
assert.strictEqual(list.concat(1), 'foo'); |
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.
@mcollina this is wrong whether or not the change in BufferList.js is applied.
- The test uses a string, probably for simplicity, but
concat()
only works with buffers. - The
n
argument (1
) was wrong and irrelevant. You could have used any argument and the test would have still passed.
FWIW the fixed test actually tests the impossible case where |
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.
LGTM, perfect
To avoid a function call `BufferList.prototype.concat()` is not called when there is only a buffer in the list. That buffer is instead accessed directly. PR-URL: #18239 Reviewed-By: Matteo Collina <[email protected]>
The `n` argument of `BufferList.prototype.concat()` is not the number of `Buffer` instances in the list, but their total length when concatenated. PR-URL: #18239 Reviewed-By: Matteo Collina <[email protected]>
Landed in e65a6e8...2313424. |
To avoid a function call `BufferList.prototype.concat()` is not called when there is only a buffer in the list. That buffer is instead accessed directly. PR-URL: #18239 Reviewed-By: Matteo Collina <[email protected]>
The `n` argument of `BufferList.prototype.concat()` is not the number of `Buffer` instances in the list, but their total length when concatenated. PR-URL: #18239 Reviewed-By: Matteo Collina <[email protected]>
First commit remove some unreachable code.
BufferList.prototype.concat()
is not called when there is only a buffer in the list.Second commit fixes a test.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
stream, test