Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8854183

Browse filesBrowse files
calvinmetcalfjasnell
authored andcommitted
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: #3300
1 parent 770cd22 commit 8854183
Copy full SHA for 8854183

File tree

Expand file treeCollapse file tree

1 file changed

+2
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-0
lines changed
Open diff view settings
Collapse file

‎lib/_stream_readable.js‎

Copy file name to clipboardExpand all lines: lib/_stream_readable.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,8 @@ function fromList(n, state) {
836836
// read it all, truncate the array.
837837
if (stringMode)
838838
ret = list.join('');
839+
else if (list.length === 1)
840+
ret = list[0];
839841
else
840842
ret = Buffer.concat(list, length);
841843
list.length = 0;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.