Skip to content

Commit aeee95d

Browse files
glennslzth
authored andcommitted
perf: compare directly to Ordering.equal instead of using isEqual
1 parent 73d5da0 commit aeee95d

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

src/Core__Array.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import * as Curry from "rescript/lib/es6/curry.js";
44
import * as Js_math from "rescript/lib/es6/js_math.js";
55
import * as Caml_option from "rescript/lib/es6/caml_option.js";
6-
import * as Core__Ordering from "./Core__Ordering.mjs";
76

87
function make(length, x) {
98
if (length <= 0) {
@@ -60,7 +59,7 @@ function compare(a, b, cmp) {
6059
return 0;
6160
}
6261
var c = Curry._2(cmp, a[i], b[i]);
63-
if (!Core__Ordering.isEqual(c)) {
62+
if (c !== 0) {
6463
return c;
6564
}
6665
_i = i + 1 | 0;

src/Core__Array.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ let rec compareFromIndex = (a, b, i, cmp, len) =>
6060
Core__Ordering.equal
6161
} else {
6262
let c = cmp(a->getUnsafe(i), b->getUnsafe(i))
63-
if c->Core__Ordering.isEqual {
63+
if c == Core__Ordering.equal {
6464
compareFromIndex(a, b, i + 1, cmp, len)
6565
} else {
6666
c

src/Core__List.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import * as Curry from "rescript/lib/es6/curry.js";
44
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
55
import * as Caml_option from "rescript/lib/es6/caml_option.js";
66
import * as Core__Array from "./Core__Array.mjs";
7-
import * as Core__Ordering from "./Core__Ordering.mjs";
87

98
function head(x) {
109
if (x) {
@@ -1005,7 +1004,7 @@ function compare(_l1, _l2, p) {
10051004
return 1;
10061005
}
10071006
var c = Curry._2(p, l1.hd, l2.hd);
1008-
if (!Core__Ordering.isEqual(c)) {
1007+
if (c !== 0) {
10091008
return c;
10101009
}
10111010
_l2 = l2.tl;

src/Core__List.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ let rec compare = (l1, l2, p) =>
695695
| (list{}, _) => Core__Ordering.less
696696
| (list{a1, ...l1}, list{a2, ...l2}) =>
697697
let c = p(a1, a2)
698-
if c->Core__Ordering.isEqual {
698+
if c == Core__Ordering.equal {
699699
compare(l1, l2, p)
700700
} else {
701701
c

0 commit comments

Comments
 (0)