Skip to content

Commit

Permalink
perf: compare directly to Ordering.equal instead of using isEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
glennsl authored and zth committed Jul 5, 2023
1 parent 73d5da0 commit aeee95d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/Core__Array.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import * as Curry from "rescript/lib/es6/curry.js";
import * as Js_math from "rescript/lib/es6/js_math.js";
import * as Caml_option from "rescript/lib/es6/caml_option.js";
import * as Core__Ordering from "./Core__Ordering.mjs";

function make(length, x) {
if (length <= 0) {
Expand Down Expand Up @@ -60,7 +59,7 @@ function compare(a, b, cmp) {
return 0;
}
var c = Curry._2(cmp, a[i], b[i]);
if (!Core__Ordering.isEqual(c)) {
if (c !== 0) {
return c;
}
_i = i + 1 | 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Core__Array.res
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ let rec compareFromIndex = (a, b, i, cmp, len) =>
Core__Ordering.equal
} else {
let c = cmp(a->getUnsafe(i), b->getUnsafe(i))
if c->Core__Ordering.isEqual {
if c == Core__Ordering.equal {
compareFromIndex(a, b, i + 1, cmp, len)
} else {
c
Expand Down
3 changes: 1 addition & 2 deletions src/Core__List.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as Curry from "rescript/lib/es6/curry.js";
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
import * as Caml_option from "rescript/lib/es6/caml_option.js";
import * as Core__Array from "./Core__Array.mjs";
import * as Core__Ordering from "./Core__Ordering.mjs";

function head(x) {
if (x) {
Expand Down Expand Up @@ -1005,7 +1004,7 @@ function compare(_l1, _l2, p) {
return 1;
}
var c = Curry._2(p, l1.hd, l2.hd);
if (!Core__Ordering.isEqual(c)) {
if (c !== 0) {
return c;
}
_l2 = l2.tl;
Expand Down
2 changes: 1 addition & 1 deletion src/Core__List.res
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ let rec compare = (l1, l2, p) =>
| (list{}, _) => Core__Ordering.less
| (list{a1, ...l1}, list{a2, ...l2}) =>
let c = p(a1, a2)
if c->Core__Ordering.isEqual {
if c == Core__Ordering.equal {
compare(l1, l2, p)
} else {
c
Expand Down

0 comments on commit aeee95d

Please sign in to comment.