Skip to content

Commit e582832

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 6264ac1 commit e582832

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/internal/fs/promises.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ async function readFileHandle(filehandle, options) {
311311
chunks.push(buffer.slice(0, bytesRead));
312312
} while (!endOfFile);
313313

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

316316
return options.encoding ? result.toString(options.encoding) : result;
317317
}

0 commit comments

Comments
 (0)