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

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
@@ -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)