mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
stream: improve read() performance more
PR-URL: https://github.com/nodejs/node/pull/28989 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
ef01d7cb66
commit
53e467db24
@ -139,7 +139,10 @@ module.exports = class BufferList {
|
||||
while (p = p.next) {
|
||||
const buf = p.data;
|
||||
const nb = (n > buf.length ? buf.length : n);
|
||||
buf.copy(ret, ret.length - n, 0, nb);
|
||||
if (nb === buf.length)
|
||||
ret.set(buf, ret.length - n);
|
||||
else
|
||||
ret.set(new Uint8Array(buf.buffer, buf.byteOffset, nb), ret.length - n);
|
||||
n -= nb;
|
||||
if (n === 0) {
|
||||
if (nb === buf.length) {
|
||||
|
Loading…
Reference in New Issue
Block a user