Browse Source

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
v5.x
Calvin Metcalf 9 years ago
committed by James M Snell
parent
commit
8854183fe5
  1. 2
      lib/_stream_readable.js

2
lib/_stream_readable.js

@ -836,6 +836,8 @@ function fromList(n, state) {
// read it all, truncate the array. // read it all, truncate the array.
if (stringMode) if (stringMode)
ret = list.join(''); ret = list.join('');
else if (list.length === 1)
ret = list[0];
else else
ret = Buffer.concat(list, length); ret = Buffer.concat(list, length);
list.length = 0; list.length = 0;

Loading…
Cancel
Save