Skip to content

Commit ea49c05

Browse files
committed
fix compare function
1 parent 6601152 commit ea49c05

File tree

3 files changed

+12
-26
lines changed

3 files changed

+12
-26
lines changed

jscomp/runtime/caml.res

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,12 @@ let float_compare = (x: float, y: float) =>
5353
}
5454

5555
let bigint_compare = (x: bigint, y: bigint) =>
56-
if x == y {
57-
0
58-
} else if x < y {
59-
-1
60-
} else if x > y {
61-
1
62-
} else if x == x {
63-
1
64-
} else if y == y {
56+
if x < y {
6557
-1
66-
} else {
58+
} else if x == y {
6759
0
60+
} else {
61+
1
6862
}
6963

7064
/* Lexical order */

lib/es6/caml.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,12 @@ function float_compare(x, y) {
4040
}
4141

4242
function bigint_compare(x, y) {
43-
if (x === y) {
44-
return 0;
45-
} else if (x < y) {
46-
return -1;
47-
} else if (x > y || x === x) {
48-
return 1;
49-
} else if (y === y) {
43+
if (x < y) {
5044
return -1;
51-
} else {
45+
} else if (x === y) {
5246
return 0;
47+
} else {
48+
return 1;
5349
}
5450
}
5551

lib/js/caml.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,12 @@ function float_compare(x, y) {
4040
}
4141

4242
function bigint_compare(x, y) {
43-
if (x === y) {
44-
return 0;
45-
} else if (x < y) {
46-
return -1;
47-
} else if (x > y || x === x) {
48-
return 1;
49-
} else if (y === y) {
43+
if (x < y) {
5044
return -1;
51-
} else {
45+
} else if (x === y) {
5246
return 0;
47+
} else {
48+
return 1;
5349
}
5450
}
5551

0 commit comments

Comments
 (0)