From 4bac5d9ddf3e557ea275c22c2cc0a351ae4056a8 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 5a37532..ab47830 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; -- 2.7.4