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 <chris@neversaw.us>
Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #3300
  • Loading branch information
calvinmetcalf authored and jasnell committed Oct 29, 2015
1 parent e04cb1e commit 4bac5d9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/_stream_readable.js
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 4bac5d9

Please sign in to comment.