Skip to content

Commit 73d5da0

Browse files
glennslzth
authored andcommitted
perf: @inline constants
1 parent 94d65c1 commit 73d5da0

9 files changed

+27
-41
lines changed

Diff for: src/Core__Array.mjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ function compare(a, b, cmp) {
4949
var lenA = a.length;
5050
var lenB = b.length;
5151
if (lenA < lenB) {
52-
return Core__Ordering.less;
52+
return -1;
5353
} else if (lenA > lenB) {
54-
return Core__Ordering.greater;
54+
return 1;
5555
} else {
5656
var _i = 0;
5757
while(true) {
5858
var i = _i;
5959
if (i === lenA) {
60-
return Core__Ordering.equal;
60+
return 0;
6161
}
6262
var c = Curry._2(cmp, a[i], b[i]);
6363
if (!Core__Ordering.isEqual(c)) {

Diff for: src/Core__Float.mjs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Generated by ReScript, PLEASE EDIT WITH CARE
22

3-
import * as Core__Ordering from "./Core__Ordering.mjs";
43

54
var Constants = {};
65

@@ -10,11 +9,11 @@ function equal(a, b) {
109

1110
function compare(a, b) {
1211
if (a < b) {
13-
return Core__Ordering.less;
12+
return -1;
1413
} else if (a > b) {
15-
return Core__Ordering.greater;
14+
return 1;
1615
} else {
17-
return Core__Ordering.equal;
16+
return 0;
1817
}
1918
}
2019

Diff for: src/Core__Int.mjs

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22

33
import * as Pervasives from "rescript/lib/es6/pervasives.js";
44
import * as Core__Array from "./Core__Array.mjs";
5-
import * as Core__Ordering from "./Core__Ordering.mjs";
65

76
function equal(a, b) {
87
return a === b;
98
}
109

1110
function compare(a, b) {
1211
if (a < b) {
13-
return Core__Ordering.less;
12+
return -1;
1413
} else if (a > b) {
15-
return Core__Ordering.greater;
14+
return 1;
1615
} else {
17-
return Core__Ordering.equal;
16+
return 0;
1817
}
1918
}
2019

Diff for: src/Core__List.mjs

+6-6
Original file line numberDiff line numberDiff line change
@@ -976,13 +976,13 @@ function compareLength(_l1, _l2) {
976976
var l1 = _l1;
977977
if (!l1) {
978978
if (l2) {
979-
return Core__Ordering.less;
979+
return -1;
980980
} else {
981-
return Core__Ordering.equal;
981+
return 0;
982982
}
983983
}
984984
if (!l2) {
985-
return Core__Ordering.greater;
985+
return 1;
986986
}
987987
_l2 = l2.tl;
988988
_l1 = l1.tl;
@@ -996,13 +996,13 @@ function compare(_l1, _l2, p) {
996996
var l1 = _l1;
997997
if (!l1) {
998998
if (l2) {
999-
return Core__Ordering.less;
999+
return -1;
10001000
} else {
1001-
return Core__Ordering.equal;
1001+
return 0;
10021002
}
10031003
}
10041004
if (!l2) {
1005-
return Core__Ordering.greater;
1005+
return 1;
10061006
}
10071007
var c = Curry._2(p, l1.hd, l2.hd);
10081008
if (!Core__Ordering.isEqual(c)) {

Diff for: src/Core__Option.mjs

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import * as Curry from "rescript/lib/es6/curry.js";
44
import * as Caml_option from "rescript/lib/es6/caml_option.js";
5-
import * as Core__Ordering from "./Core__Ordering.mjs";
65

76
function filter(opt, p) {
87
var p$1 = Curry.__1(p);
@@ -96,12 +95,12 @@ function compare(a, b, cmp) {
9695
if (b !== undefined) {
9796
return Curry._2(cmp, Caml_option.valFromOption(a), Caml_option.valFromOption(b));
9897
} else {
99-
return Core__Ordering.greater;
98+
return 1;
10099
}
101100
} else if (b !== undefined) {
102-
return Core__Ordering.less;
101+
return -1;
103102
} else {
104-
return Core__Ordering.equal;
103+
return 0;
105104
}
106105
}
107106

Diff for: src/Core__Ordering.mjs

-9
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,7 @@ function fromInt(n) {
2727
}
2828
}
2929

30-
var less = -1;
31-
32-
var equal = 0;
33-
34-
var greater = 1;
35-
3630
export {
37-
less ,
38-
equal ,
39-
greater ,
4031
isLess ,
4132
isEqual ,
4233
isGreater ,

Diff for: src/Core__Ordering.res

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
type t = float
22

3-
let less = -1.
4-
let equal = 0.
5-
let greater = 1.
3+
@inline let less = -1.
4+
@inline let equal = 0.
5+
@inline let greater = 1.
66

77
let isLess = ord => ord < equal
88
let isEqual = ord => ord == equal

Diff for: src/Core__Result.mjs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Generated by ReScript, PLEASE EDIT WITH CARE
22

33
import * as Curry from "rescript/lib/es6/curry.js";
4-
import * as Core__Ordering from "./Core__Ordering.mjs";
54

65
function getExn(x) {
76
if (x.TAG === /* Ok */0) {
@@ -92,12 +91,12 @@ function compare(a, b, f) {
9291
if (b.TAG === /* Ok */0) {
9392
return Curry._2(f, a._0, b._0);
9493
} else {
95-
return Core__Ordering.greater;
94+
return 1;
9695
}
9796
} else if (b.TAG === /* Ok */0) {
98-
return Core__Ordering.less;
97+
return -1;
9998
} else {
100-
return Core__Ordering.equal;
99+
return 0;
101100
}
102101
}
103102

Diff for: src/Core__String.mjs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
// Generated by ReScript, PLEASE EDIT WITH CARE
22

3-
import * as Core__Ordering from "./Core__Ordering.mjs";
43

54
function equal(a, b) {
65
return a === b;
76
}
87

98
function compare(a, b) {
109
if (a < b) {
11-
return Core__Ordering.less;
10+
return -1;
1211
} else if (a > b) {
13-
return Core__Ordering.greater;
12+
return 1;
1413
} else {
15-
return Core__Ordering.equal;
14+
return 0;
1615
}
1716
}
1817

0 commit comments

Comments
 (0)