From 8854183fe565fafceb6b30149c1026401b60e4eb Mon Sep 17 00:00:00 2001 From: Calvin Metcalf Date: Fri, 9 Oct 2015 14:50:11 -0400 Subject: [PATCH] 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 Reviewed-By: James M Snell PR-URL: https://github.com/nodejs/node/pull/3300 --- lib/_stream_readable.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 5a375321615a7f..ab47830767c525 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;