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: nodejs#50621
  • Loading branch information
Septa2112 committed Dec 4, 2023
1 parent 951d00d commit 0e48964
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 0e48964

Please sign in to comment.