Skip to content

Commit

Permalink
stream: improve read() performance more
Browse files Browse the repository at this point in the history
PR-URL: #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>
  • 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.