Skip to content

Commit e6e6b07

Browse files
committed
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 80c9fd9 commit e6e6b07

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

lib/buffer.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,6 @@ function fromArrayBuffer(obj, byteOffset, length) {
354354
if (length !== length) {
355355
length = 0;
356356
} else if (length > 0) {
357-
length = (length < Number.MAX_SAFE_INTEGER ?
358-
length : Number.MAX_SAFE_INTEGER);
359357
if (length > maxLength)
360358
throw new RangeError("'length' is out of bounds");
361359
} else {

0 commit comments

Comments
 (0)