Skip to content

Commit

Permalink
util: improve performance of function areSimilarFloatArrays
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Septa2112 authored and richardlau committed Mar 25, 2024
1 parent 9f88f40 commit c3b89c3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/internal/util/comparisons.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const {
StringPrototypeValueOf,
SymbolPrototypeValueOf,
TypedArrayPrototypeGetSymbolToStringTag,
TypedArrayPrototypeGetByteLength,
Uint8Array,
} = primordials;

Expand Down Expand Up @@ -71,7 +72,8 @@ function areSimilarFloatArrays(a, b) {
if (a.byteLength !== b.byteLength) {
return false;
}
for (let offset = 0; offset < a.byteLength; offset++) {
const len = TypedArrayPrototypeGetByteLength(a);
for (let offset = 0; offset < len; offset++) {
if (a[offset] !== b[offset]) {
return false;
}
Expand Down

0 comments on commit c3b89c3

Please sign in to comment.