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 <ruben@bridgewater.de>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Septa2112 authored and RafaelGSS committed Dec 15, 2023
1 parent 048349e commit cd891b3
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 cd891b3

Please sign in to comment.