diff --git a/benchmark/buffers/buffer-concat.js b/benchmark/buffers/buffer-concat.js index 26edc649d8d349..51704978872940 100644 --- a/benchmark/buffers/buffer-concat.js +++ b/benchmark/buffers/buffer-concat.js @@ -3,7 +3,7 @@ const common = require('../common.js'); const bench = common.createBenchmark(main, { pieces: [4, 16], - pieceSize: [1, 16, 256], + pieceSize: [0, 1, 16, 256], withTotalLength: [0, 1], n: [8e5], }); diff --git a/lib/buffer.js b/lib/buffer.js index c9f45d333886d3..3148a6b4e4d9d3 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -590,6 +590,9 @@ Buffer.concat = function concat(list, length) { validateOffset(length, 'length'); } + if (length === 0) + return new FastBuffer(); + const buffer = Buffer.allocUnsafe(length); let pos = 0; for (let i = 0; i < list.length; i++) {