Uh oh!
There was an error while loading. Please reload this page.
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 |
lpinca
commented
Jan 20, 2018
MoonBall
commented
Jan 20, 2018
ok. I agree. |
targos
commented
Jan 20, 2018
/cc @nodejs/streams |
mcollina
commented
Jan 20, 2018
I'm not super comfortable with this change. |
lpinca
commented
Jan 20, 2018
Do you mean if |
mcollina
commented
Jan 20, 2018
Can you restore the test then? |
| const copy = list.concat(3); | ||
| assert.strictEqual(list.concat(1), 'foo'); |
There was a problem hiding this comment.
@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
nargument (1) was wrong and irrelevant. You could have used any argument and the test would have still passed.
lpinca
commented
Jan 20, 2018
FWIW the fixed test actually tests the impossible case where |
lpinca
commented
Jan 21, 2018
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 <matteo.collina@gmail.com>
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 <matteo.collina@gmail.com>
lpinca
commented
Jan 24, 2018
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 <matteo.collina@gmail.com>
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 <matteo.collina@gmail.com>
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