Skip to content

Commit 4441388

Browse files
committed
save few bytes by changing type definition
1 parent a23cc9e commit 4441388

8 files changed

+194
-190
lines changed

jscomp/core/lam_compile_external_call.ml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,16 @@ let append_list x xs =
9191
This would not work with [NonNullString]
9292
*)
9393
let ocaml_to_js_eff
94-
({arg_label; arg_type }: External_arg_spec.t_noname)
94+
~(arg_label : External_arg_spec.label_noname)
95+
~(arg_type : External_arg_spec.attr)
9596
(raw_arg : E.t)
9697
: arg_expression * E.t list =
9798
let arg =
9899
match arg_label with
99100
| Optional ->
100101
Js_of_lam_option.get_default_undefined_from_optional raw_arg
101-
| Label {cst = None;_} | Empty -> raw_arg
102-
| Label {cst = Some _;_}
102+
| Label | Empty -> raw_arg
103+
| LabelCst _
103104
| EmptyCst _
104105
-> assert false in
105106
match arg_type with
@@ -176,16 +177,17 @@ let assemble_args_no_splice call_loc ffi
176177
| [], _
177178
-> assert (args = []) ; empty_pair
178179
| { arg_label = EmptyCst cst ; _} :: labels, args
179-
| { arg_label = Label {cst = Some cst;_}; _} :: labels, args ->
180+
| { arg_label = LabelCst {cst ;}; _} :: labels, args ->
180181
let accs, eff = aux labels args in
181182
Lam_compile_const.translate_arg_cst cst :: accs, eff
182-
| ({arg_label = Empty | Label {cst = None;_} | Optional ;_ } as arg_kind) ::labels,
183+
| {arg_label = Empty | Label | Optional as arg_label ; arg_type } ::labels,
183184
arg :: args
184185
->
185186
let accs, eff = aux labels args in
186-
let acc, new_eff = ocaml_to_js_eff arg_kind arg in
187+
let acc, new_eff = ocaml_to_js_eff
188+
~arg_label ~arg_type arg in
187189
append_list acc accs, Ext_list.append new_eff eff
188-
| { arg_label = Empty | Label {cst = None;_} | Optional ; _ } :: _ , []
190+
| { arg_label = Empty | Label | Optional ; _ } :: _ , []
189191
-> assert false
190192
in
191193
let args, eff = aux arg_types args in
@@ -202,10 +204,10 @@ let assemble_args_has_splice call_loc ffi (arg_types : specs) (args : exprs)
202204
match labels, args with
203205
| [] , _ -> assert (args = []); empty_pair
204206
| { arg_label = EmptyCst cst ; _} :: labels , args
205-
| { arg_label = Label {cst = Some cst;_}; _} :: labels , args ->
207+
| { arg_label = LabelCst {cst}; _} :: labels , args ->
206208
let accs, eff = aux labels args in
207209
Lam_compile_const.translate_arg_cst cst :: accs, eff
208-
| ({arg_label = Empty | Label {cst = None;_} | Optional ;_ } as arg_kind) ::labels,
210+
| ({arg_label = Empty | Label | Optional as arg_label; arg_type }) ::labels,
209211
arg :: args
210212
->
211213
let accs, eff = aux labels args in
@@ -214,10 +216,10 @@ let assemble_args_has_splice call_loc ffi (arg_types : specs) (args : exprs)
214216
Ext_list.append ls accs, eff
215217
| _ ->
216218
if args = [] then dynamic := true ;
217-
let acc, new_eff = ocaml_to_js_eff arg_kind arg in
219+
let acc, new_eff = ocaml_to_js_eff ~arg_type ~arg_label arg in
218220
append_list acc accs, Ext_list.append new_eff eff
219221
end
220-
| { arg_label = Empty | Label {cst = None;_} | Optional ; _ } :: _ , []
222+
| { arg_label = Empty | Label | Optional ; _ } :: _ , []
221223
-> assert false
222224
in
223225
let args, eff = aux arg_types args in

jscomp/core/lam_compile_external_call.mli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131

3232
(** Compile ocaml external function call to JS IR. *)
3333
val ocaml_to_js_eff :
34-
External_arg_spec.t_noname ->
34+
arg_label:External_arg_spec.label_noname ->
35+
arg_type:External_arg_spec.attr ->
3536
J.expression ->
3637
Js_of_lam_variant.arg_expression * J.expression list
3738

jscomp/core/lam_compile_external_obj.ml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ let assemble_obj_args (labels : External_arg_spec.t list) (args : J.expression
5858
| ({arg_label = Label {name = label; cst = None} } as arg_kind)::labels, arg::args
5959
->
6060
let accs, eff, assign = aux labels args in
61-
let acc, new_eff = Lam_compile_external_call.ocaml_to_js_eff {arg_label = Label {cst = None}; arg_type=arg_kind.arg_type} arg in
61+
let acc, new_eff = Lam_compile_external_call.ocaml_to_js_eff ~arg_label:Label ~arg_type:arg_kind.arg_type arg in
6262
begin match acc with
6363
| Splice2 _
6464
| Splice0 -> assert false
@@ -72,7 +72,7 @@ let assemble_obj_args (labels : External_arg_spec.t list) (args : J.expression
7272
Js_of_lam_option.destruct_optional arg
7373
~for_sure_none:r
7474
~for_sure_some:(fun x -> let acc, new_eff = Lam_compile_external_call.ocaml_to_js_eff
75-
({arg_label = Label {cst = None}; arg_type} : External_arg_spec.t_noname) x in
75+
~arg_label:Label ~arg_type x in
7676
begin match acc with
7777
| Splice2 _
7878
| Splice0 -> assert false
@@ -111,8 +111,8 @@ let assemble_obj_args (labels : External_arg_spec.t list) (args : J.expression
111111
| None ->
112112
let acc,new_eff =
113113
Lam_compile_external_call.ocaml_to_js_eff
114-
{arg_label =
115-
Empty; arg_type = xlabel.arg_type }
114+
~arg_label:
115+
Empty ~arg_type:xlabel.arg_type
116116
(Js_of_lam_option.val_from_option arg) in
117117
begin match acc with
118118
| Splice1 v ->
@@ -130,10 +130,9 @@ let assemble_obj_args (labels : External_arg_spec.t list) (args : J.expression
130130
let arg = E.var id in
131131
let acc,new_eff =
132132
Lam_compile_external_call.ocaml_to_js_eff
133-
{arg_label =
134-
Empty;
135-
arg_type = xlabel.arg_type
136-
}
133+
~arg_label:
134+
Empty
135+
~arg_type:xlabel.arg_type
137136
(Js_of_lam_option.val_from_option arg) in
138137
begin match acc with
139138
| Splice1 v ->

jscomp/main/builtin_cmi_datasets.ml

Lines changed: 144 additions & 144 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)