Skip to content

Commit 32d65c0

Browse files
kylo5abyUlisesGascon
authored andcommitted
buffer: improve Buffer.equals performance
PR-URL: #50621 Refs: #50620 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Debadree Chatterjee <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent ea61261 commit 32d65c0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎lib/buffer.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -860,11 +860,11 @@ Buffer.prototype.equals = function equals(otherBuffer){
860860

861861
if(this===otherBuffer)
862862
returntrue;
863-
864-
if(this.byteLength!==otherBuffer.byteLength)
863+
constlen=TypedArrayPrototypeGetByteLength(this);
864+
if(len!==TypedArrayPrototypeGetByteLength(otherBuffer))
865865
returnfalse;
866866

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

870870
letINSPECT_MAX_BYTES=50;

0 commit comments

Comments
(0)