diff options
author | Calvin Metcalf <cmetcalf@appgeo.com> | 2015-10-09 14:50:11 -0400 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2015-10-14 12:28:52 -0700 |
commit | 8854183fe565fafceb6b30149c1026401b60e4eb (patch) | |
tree | 648aa4a06915a131cefacb83bc213aeaca2caf1e /lib/_stream_readable.js | |
parent | 770cd229f9638064b6f39b038b2140bbd6a7a543 (diff) | |
download | android-node-v8-8854183fe565fafceb6b30149c1026401b60e4eb.tar.gz android-node-v8-8854183fe565fafceb6b30149c1026401b60e4eb.tar.bz2 android-node-v8-8854183fe565fafceb6b30149c1026401b60e4eb.zip |
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
Diffstat (limited to 'lib/_stream_readable.js')
-rw-r--r-- | lib/_stream_readable.js | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 5a37532161..ab47830767 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -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; |