From d220dd97d7cc9e60042c0fa34c0899b10560908f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 7 Jul 2017 22:59:36 -0700 Subject: [PATCH] buffer: remove MAX_SAFE_INTEGER check on length MAX_SAFE_INTEGER is millions of times larger than the largest buffer allowed in Node.js. There is no need to squash the length down to MAX_SAFE_INTEGER. Removing that check results in a small but statistically significant increase for Buffer.from() operating on ArrayBuffers in some situations. --- lib/buffer.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index cfe30808106961..f8d615ee0c23fb 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -354,8 +354,6 @@ function fromArrayBuffer(obj, byteOffset, length) { if (length !== length) { length = 0; } else if (length > 0) { - length = (length < Number.MAX_SAFE_INTEGER ? - length : Number.MAX_SAFE_INTEGER); if (length > maxLength) throw new RangeError("'length' is out of bounds"); } else {