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 <chris@neversaw.us>
Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/3300
This commit is contained in:
Calvin Metcalf authored and James M Snell committed 2015-10-14 12:28:52 -07:00
1 parent 770cd229f9
commit 8854183fe5
1 file changed
+2
+2
View File
@@ -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;