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 b10f698 commit 16e579f
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 = 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;
Expand Down

0 comments on commit 16e579f

Please sign in to comment.