buffer: improve Buffer.equals performance
PR-URL: https://github.com/nodejs/node/pull/50621 Refs: https://github.com/nodejs/node/issues/50620 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
parent
f662c9b63f
commit
89c66ae1eb
@ -860,11 +860,11 @@ Buffer.prototype.equals = function equals(otherBuffer) {
|
||||
|
||||
if (this === otherBuffer)
|
||||
return true;
|
||||
|
||||
if (this.byteLength !== otherBuffer.byteLength)
|
||||
const len = TypedArrayPrototypeGetByteLength(this);
|
||||
if (len !== TypedArrayPrototypeGetByteLength(otherBuffer))
|
||||
return false;
|
||||
|
||||
return this.byteLength === 0 || _compare(this, otherBuffer) === 0;
|
||||
return len === 0 || _compare(this, otherBuffer) === 0;
|
||||
};
|
||||
|
||||
let INSPECT_MAX_BYTES = 50;
|
||||
|
Loading…
x
Reference in New Issue
Block a user