Skip to content

Commit

Permalink
stream: improve read() performance more
Browse files Browse the repository at this point in the history
PR-URL: nodejs#28989
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
mscdex committed Aug 9, 2019
1 parent ef01d7c commit 53e467d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/internal/streams/buffer_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 53e467d

Please sign in to comment.