Skip to content

Commit 8854183

Browse files
calvinmetcalfjasnell
authored andcommitted
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. Reviewed-By: Chris Dickinson <[email protected]> Reviewed-By: James M Snell <[email protected]> PR-URL: #3300
1 parent 770cd22 commit 8854183

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/_stream_readable.js

+2
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,8 @@ function fromList(n, state) {
836836
// read it all, truncate the array.
837837
if (stringMode)
838838
ret = list.join('');
839+
else if (list.length === 1)
840+
ret = list[0];
839841
else
840842
ret = Buffer.concat(list, length);
841843
list.length = 0;

0 commit comments

Comments
 (0)