Skip to content

Commit

Permalink
improve Buffer.equals performance
Browse files Browse the repository at this point in the history
  • Loading branch information
kylo5aby committed Nov 8, 2023
1 parent 33704c4 commit 2aaa6d3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,11 +860,11 @@ Buffer.prototype.equals = function equals(otherBuffer) {

if (this === otherBuffer)
return true;

if (this.byteLength !== otherBuffer.byteLength)
const len = this.byteLength;
if (len !== otherBuffer.byteLength)
return false;

return this.byteLength === 0 || _compare(this, otherBuffer) === 0;
return len === 0 || _compare(this, otherBuffer) === 0;
};

let INSPECT_MAX_BYTES = 50;
Expand Down

0 comments on commit 2aaa6d3

Please sign in to comment.