Skip to content

Commit d61cb9c

Browse files
committed
buffer: improve Buffer.equals performance
1 parent b10f698 commit d61cb9c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/buffer.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -860,11 +860,11 @@ Buffer.prototype.equals = function equals(otherBuffer) {
860860

861861
if (this === otherBuffer)
862862
return true;
863-
864-
if (this.byteLength !== otherBuffer.byteLength)
863+
const len = TypedArrayPrototypeGetByteLength(this);
864+
if (len !== TypedArrayPrototypeGetByteLength(otherBuffer))
865865
return false;
866866

867-
return this.byteLength === 0 || _compare(this, otherBuffer) === 0;
867+
return len === 0 || _compare(this, otherBuffer) === 0;
868868
};
869869

870870
let INSPECT_MAX_BYTES = 50;

0 commit comments

Comments
 (0)