diff --git a/lib/buffer.js b/lib/buffer.js index 8f4e34d289fc27..dc2b656d7a7a33 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -247,6 +247,11 @@ Buffer.concat = function(list, length) { if (!Array.isArray(list)) throw new TypeError('list argument must be an Array of Buffers.'); + if (list.length === 0) + return new Buffer(0); + else if (list.length === 1) + return list[0]; + if (length === undefined) { length = 0; for (var i = 0; i < list.length; i++) @@ -255,11 +260,6 @@ Buffer.concat = function(list, length) { length = length >>> 0; } - if (list.length === 0) - return new Buffer(0); - else if (list.length === 1) - return list[0]; - var buffer = new Buffer(length); var pos = 0; for (var i = 0; i < list.length; i++) {