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? |
|
|
||
| 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.
|
FWIW the fixed test actually tests the impossible case where |
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>
|
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