Skip to content

Commit ad12fef

Browse files
addaleaxtargos
authored andcommitted
fs: only use Buffer.concat in promises.readFile when necessary
PR-URL: #37127 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Zijian Liu <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 8cecce3 commit ad12fef

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/internal/fs/promises.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ async function readFileHandle(filehandle, options) {
331331
ArrayPrototypePush(chunks, buffer.slice(0, bytesRead));
332332
} while (!endOfFile);
333333

334-
const result = Buffer.concat(chunks);
334+
const result = chunks.length === 1 ? chunks[0] : Buffer.concat(chunks);
335335

336336
return options.encoding ? result.toString(options.encoding) : result;
337337
}

0 commit comments

Comments
 (0)