Skip to content

Commit cd891b3

Browse files
Septa2112RafaelGSS
authored andcommitted
util: improve performance of function areSimilarFloatArrays
Improve performance of areSimilarFloatArrays by using primordial. Refs: #50621 PR-URL: #51040 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 048349e commit cd891b3

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎lib/internal/util/comparisons.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const {
2121
StringPrototypeValueOf,
2222
SymbolPrototypeValueOf,
2323
TypedArrayPrototypeGetSymbolToStringTag,
24+
TypedArrayPrototypeGetByteLength,
2425
Uint8Array,
2526
}=primordials;
2627

@@ -71,7 +72,8 @@ function areSimilarFloatArrays(a, b) {
7172
if(a.byteLength!==b.byteLength){
7273
returnfalse;
7374
}
74-
for(letoffset=0;offset<a.byteLength;offset++){
75+
constlen=TypedArrayPrototypeGetByteLength(a);
76+
for(letoffset=0;offset<len;offset++){
7577
if(a[offset]!==b[offset]){
7678
returnfalse;
7779
}

0 commit comments

Comments
 (0)