Skip to content

Commit bed1344

Browse files
Trottaddaleax
authored andcommitted
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. PR-URL: #14131 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
1 parent de84249 commit bed1344

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

lib/buffer.js

-2
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,6 @@ function fromArrayBuffer(obj, byteOffset, length) {
353353
if (length !== length) {
354354
length = 0;
355355
} else if (length > 0) {
356-
length = (length < Number.MAX_SAFE_INTEGER ?
357-
length : Number.MAX_SAFE_INTEGER);
358356
if (length > maxLength)
359357
throw new RangeError("'length' is out of bounds");
360358
} else {

0 commit comments

Comments
 (0)