@@ -923,7 +923,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda =
923923 let targ = transl_exp arg in
924924 match lbl.lbl_repres with
925925 | Record_float_unused -> assert false
926- | Record_regular | Record_optional_labels ->
926+ | Record_regular ->
927927 Lprim (Pfield (lbl.lbl_pos, Lambda. fld_record lbl), [targ], e.exp_loc)
928928 | Record_inlined _ ->
929929 Lprim
@@ -938,8 +938,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda =
938938 let access =
939939 match lbl.lbl_repres with
940940 | Record_float_unused -> assert false
941- | Record_regular | Record_optional_labels ->
942- Psetfield (lbl.lbl_pos, Lambda. fld_record_set lbl)
941+ | Record_regular -> Psetfield (lbl.lbl_pos, Lambda. fld_record_set lbl)
943942 | Record_inlined _ ->
944943 Psetfield (lbl.lbl_pos, Lambda. fld_record_inline_set lbl)
945944 | Record_unboxed _ -> assert false
@@ -1159,6 +1158,7 @@ and transl_record loc env fields repres opt_init_expr =
11591158 else lambda
11601159 | _ -> (
11611160 let size = Array. length fields in
1161+ let optional = Ext_array. exists fields (fun (ld , _ ) -> ld.lbl_optional) in
11621162 (* Determine if there are "enough" fields (only relevant if this is a
11631163 functional-style record update *)
11641164 let no_init =
@@ -1167,12 +1167,7 @@ and transl_record loc env fields repres opt_init_expr =
11671167 | _ -> false
11681168 in
11691169 if
1170- no_init
1171- || size < 20
1172- &&
1173- match repres with
1174- | Record_optional_labels -> false
1175- | _ -> true
1170+ no_init || (size < 20 && not optional)
11761171 (* TODO: More strategies
11771172 3 + 2 * List.length lbl_expr_list >= size (density)
11781173 *)
@@ -1188,8 +1183,7 @@ and transl_record loc env fields repres opt_init_expr =
11881183 let access =
11891184 match repres with
11901185 | Record_float_unused -> assert false
1191- | Record_regular | Record_optional_labels ->
1192- Pfield (i, Lambda. fld_record lbl)
1186+ | Record_regular -> Pfield (i, Lambda. fld_record lbl)
11931187 | Record_inlined _ -> Pfield (i, Lambda. fld_record_inline lbl)
11941188 | Record_unboxed _ -> assert false
11951189 | Record_extension ->
@@ -1213,10 +1207,10 @@ and transl_record loc env fields repres opt_init_expr =
12131207 | Record_float_unused -> assert false
12141208 | Record_regular ->
12151209 Lconst
1216- (Const_block ( Lambda. blk_record fields mut Record_regular , cl))
1217- | Record_optional_labels ->
1218- Lconst
1219- ( Const_block ( Lambda. blk_record fields mut Record_optional , cl))
1210+ (Const_block
1211+ ( Lambda. blk_record fields mut
1212+ ( if optional then Record_optional else Record_regular ),
1213+ cl ))
12201214 | Record_inlined {tag; name; num_nonconsts; attrs} ->
12211215 Lconst
12221216 (Const_block
@@ -1233,10 +1227,9 @@ and transl_record loc env fields repres opt_init_expr =
12331227 match repres with
12341228 | Record_regular ->
12351229 Lprim
1236- (Pmakeblock (Lambda. blk_record fields mut Record_regular ), ll, loc)
1237- | Record_optional_labels ->
1238- Lprim
1239- ( Pmakeblock (Lambda. blk_record fields mut Record_optional ),
1230+ ( Pmakeblock
1231+ (Lambda. blk_record fields mut
1232+ (if optional then Record_optional else Record_regular )),
12401233 ll,
12411234 loc )
12421235 | Record_float_unused -> assert false
@@ -1277,7 +1270,7 @@ and transl_record loc env fields repres opt_init_expr =
12771270 let upd =
12781271 match repres with
12791272 | Record_float_unused -> assert false
1280- | Record_regular | Record_optional_labels ->
1273+ | Record_regular ->
12811274 Psetfield (lbl.lbl_pos, Lambda. fld_record_set lbl)
12821275 | Record_inlined _ ->
12831276 Psetfield (lbl.lbl_pos, Lambda. fld_record_inline_set lbl)
0 commit comments