Skip to content

Commit c3b89c3

Browse files
Septa2112richardlau
authored andcommitted
util: improve performance of function areSimilarFloatArrays
Improve performance of areSimilarFloatArrays by using primordial. Refs: #50621 PR-URL: #51040 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 9f88f40 commit c3b89c3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/internal/util/comparisons.js

+3-1
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
return false;
7374
}
74-
for (let offset = 0; offset < a.byteLength; offset++) {
75+
const len = TypedArrayPrototypeGetByteLength(a);
76+
for (let offset = 0; offset < len; offset++) {
7577
if (a[offset] !== b[offset]) {
7678
return false;
7779
}

0 commit comments

Comments
 (0)