Skip to content

Commit 8c462af

Browse files
committed
stream: avoid unnecessary concat of a single buffer.
Avoids doing a buffer.concat on the internal buffer when that array has only a single thing in it.
1 parent 775c01e commit 8c462af

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/_stream_readable.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,8 @@ function fromList(n, state) {
826826
// read it all, truncate the array.
827827
if (stringMode)
828828
ret = list.join('');
829+
else if (list.length === 1)
830+
ret = list[0];
829831
else
830832
ret = Buffer.concat(list, length);
831833
list.length = 0;

0 commit comments

Comments
 (0)