Skip to content

Commit

Permalink
Runtime: remove useless switch case
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Sep 26, 2024
1 parent 21392ad commit eb92c0d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
1 change: 0 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"rules": {
"recommended": true,
"complexity": {
"noUselessSwitchCase": "off",
"noUselessTernary": "off",
"useArrowFunction": "off",
"useOptionalChain": "off"
Expand Down
3 changes: 1 addition & 2 deletions runtime/compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ function caml_compare_val(a, b, total) {
if (a > b) return 1;
}
break;
case 246: // Lazy_tag
default: // Block with other tag
default: // Lazy_tag or Block with other tag
if (caml_is_continuation_tag(tag_a)) {
caml_invalid_argument("compare: continuation value");
break;
Expand Down
22 changes: 8 additions & 14 deletions runtime/internalMod.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,10 @@ function caml_CamlinternalMod_init_mod(loc, shape) {
//Version: < 4.13
function caml_CamlinternalMod_update_mod(shape, real, x) {
if (typeof shape === "number")
switch (shape) {
case 0: //function
case 1: //lazy
case 2: //class
default:
caml_update_dummy(real, x);
}
//function
//lazy
//class
caml_update_dummy(real, x);
else
switch (shape[0]) {
case 0: //module
Expand Down Expand Up @@ -123,13 +120,10 @@ function caml_CamlinternalMod_init_mod(loc, shape, cont) {
function caml_CamlinternalMod_update_mod(shape, real, x, cont) {
function loop(shape, real, x) {
if (typeof shape === "number")
switch (shape) {
case 0: //function
case 1: //lazy
case 2: //class
default:
caml_update_dummy(real, x);
}
//function
//lazy
//class
caml_update_dummy(real, x);
else
switch (shape[0]) {
case 0: //module
Expand Down
6 changes: 5 additions & 1 deletion runtime/marshal.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,11 @@ function caml_marshal_data_size(s, ofs) {
);
}
break;
case 0x8495a6bf: /* Intext_magic_number_big */
case 0x8495a6bf /* Intext_magic_number_big */:
caml_failwith(
"Marshal.data_size: object too large to be read back on a 32-bit platform",
);
break;
default:
caml_failwith("Marshal.data_size: bad object");
break;
Expand Down

0 comments on commit eb92c0d

Please sign in to comment.