Skip to content

Commit

Permalink
stream: avoid unnecessary concat of a single buffer.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
calvinmetcalf authored and jasnell committed Oct 14, 2015
1 parent 770cd22 commit 8854183
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,8 @@ function fromList(n, state) {
// read it all, truncate the array.
if (stringMode)
ret = list.join('');
else if (list.length === 1)
ret = list[0];
else
ret = Buffer.concat(list, length);
list.length = 0;
Expand Down

0 comments on commit 8854183

Please sign in to comment.