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 <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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)