Skip to content

Commit 2aaa6d3

Browse files
committed
improve Buffer.equals performance
1 parent 33704c4 commit 2aaa6d3

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 = this.byteLength;
864+
if (len !== otherBuffer.byteLength)
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)