Skip to content

Commit 50f4d60

Browse files
committed
Add example where some numerical ad hoc optimization kicks in.
1 parent 457909f commit 50f4d60

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

jscomp/test/variantsMatching.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
'use strict';
22

33

4-
function foo(x) {
4+
function toEnum(x) {
5+
return x;
6+
}
7+
8+
function toString(x) {
59
switch (x) {
610
case /* A */0 :
711
return "A";
@@ -114,7 +118,8 @@ function third2(l) {
114118
}
115119
}
116120

117-
exports.foo = foo;
121+
exports.toEnum = toEnum;
122+
exports.toString = toString;
118123
exports.bar = bar;
119124
exports.and_ = and_;
120125
exports.id = id;

jscomp/test/variantsMatching.res

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
type t = A | B | C | D | E
22

3-
let foo = x =>
3+
let toEnum = x =>
4+
switch x {
5+
| A => 0
6+
| B => 1
7+
| C => 2
8+
| D => 3
9+
| E => 4
10+
}
11+
12+
let toString = x =>
413
switch x {
514
| A => "A"
615
| B => "B"

0 commit comments

Comments
 (0)