Skip to content

Commit 996dd6c

Browse files
authored
Merge pull request #4272 from BuckleScript/no_deriving_abstract
code optimize: better handling option unpacking
2 parents 922800f + fd8ba27 commit 996dd6c

29 files changed

+1712
-1995
lines changed

jscomp/core/lam_pass_remove_alias.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ let simplify_alias
5656
| l ->
5757
Lam.prim ~primitive ~args:[l] loc
5858
end
59-
| Lprim {primitive = Pval_from_option | Pval_from_option_not_nest; args = [Lvar v]} as x ->
59+
| Lprim {primitive = (Pval_from_option | Pval_from_option_not_nest as p ); args = [Lvar v as lvar ]} as x ->
6060
begin match Hash_ident.find_opt meta.ident_tbl v with
6161
| Some (OptionalBlock (l,_)) -> l
62-
| _ -> x
62+
| _ -> if p = Pval_from_option_not_nest then lvar else x
6363
end
6464
| Lglobal_module _ -> lam
6565
| Lprim {primitive; args; loc }

jscomp/main/builtin_cmj_datasets.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(* db516cc4d41ba37a0dc17186ca11d5fa *)
1+
(* 42f46a098327536b6ed6d74e5f60e014 *)
22
let module_names : string array = Obj.magic (
33
"Gc" (* 220 *),
44
"Js" (* 23 *),
@@ -256,7 +256,7 @@ let module_data : string array = Obj.magic (
256256
(* CamlinternalMod *)"\132\149\166\190\000\000\000\003\000\000\000\001\000\000\000\003\000\000\000\003\160\128A",
257257
(* Js_typed_array2 *)"\132\149\166\190\000\000\000\003\000\000\000\001\000\000\000\003\000\000\000\003\160\128A",
258258
(* CamlinternalLazy *)"\132\149\166\190\000\000\000Y\000\000\000\022\000\000\000L\000\000\000E\160\192\176%force\144\160\160A@@@\176)force_val\144\160\160A@@@\1760force_lazy_block\144\160\160A@@@\1764force_val_lazy_block\144\160\160A@@@A",
259-
(* Belt_MutableQueue *)"\132\149\166\190\000\000\002(\000\000\000\168\000\000\002\031\000\000\002\004\160\b\000\000T\000\176#add\144\160\160B@@@\176#map\144\160\160B@@@\176#pop\144\160\160A@@@\176$copy\144\160\160A@@@\176$make\144\160\160A@@\144\180A\160\176\001\003\245%param@@\151\176\177@\146\176&length%first$lastA\160\146\144@\160\146A\160\146A@\176\192;others/belt_MutableQueue.mlb\001\005\176\001\005\180\192\004\002e\001\005\220\001\005\239@\176$mapU\144\160\160B@@@\176$peek\144\160\160A@@@\176$size\144\160\160A@@\144\180A\160\176\001\004\181!q@@\151\176\162@\160\004&A\160\144\004\b@\176\192\004\030\001\000\163\001\016\002\001\016\004\192\004\031\001\000\163\001\016\002\001\016\012@\176%clear\144\160\160A@@@\176&popExn\144\160\160A@@@\176&reduce\144\160\160C@@@\176'forEach\144\160\160B@@@\176'isEmpty\144\160\160A@@\144\180A\160\176\001\004\179!q@@\151\176\152@\160\151\176\162@\160\004QA\160\144\004\012@\176\192\004I\001\000\160\001\015\229\001\015\231\192\004J\001\000\160\001\015\229\001\015\239@\160\146\144@@\176\004\006\192\004O\001\000\160\001\015\229\001\015\243@\176'peekExn\144\160\160A@@@\176'reduceU\144\160\160C@@@\176'toArray\144\160\160A@@@\176(forEachU\144\160\160B@@@\176(transfer\144\160\160B@@@\176)fromArray\144\160\160A@@@\176,popUndefined\144\160\160A@@@\176-peekUndefined\144\160\160A@@@A",
259+
(* Belt_MutableQueue *)"\132\149\166\190\000\000\002(\000\000\000\168\000\000\002\031\000\000\002\004\160\b\000\000T\000\176#add\144\160\160B@@@\176#map\144\160\160B@@@\176#pop\144\160\160A@@@\176$copy\144\160\160A@@@\176$make\144\160\160A@@\144\180A\160\176\001\003\245%param@@\151\176\177@\146\176&length%first$lastA\160\146\144@\160\146A\160\146A@\176\192;others/belt_MutableQueue.mlb\001\005\176\001\005\180\192\004\002e\001\005\220\001\005\239@\176$mapU\144\160\160B@@@\176$peek\144\160\160A@@@\176$size\144\160\160A@@\144\180A\160\176\001\004\181!q@@\151\176\162@\160\004&A\160\144\004\b@\176\192\004\030\001\000\163\001\016Y\001\016[\192\004\031\001\000\163\001\016Y\001\016c@\176%clear\144\160\160A@@@\176&popExn\144\160\160A@@@\176&reduce\144\160\160C@@@\176'forEach\144\160\160B@@@\176'isEmpty\144\160\160A@@\144\180A\160\176\001\004\179!q@@\151\176\152@\160\151\176\162@\160\004QA\160\144\004\012@\176\192\004I\001\000\160\001\016<\001\016>\192\004J\001\000\160\001\016<\001\016F@\160\146\144@@\176\004\006\192\004O\001\000\160\001\016<\001\016J@\176'peekExn\144\160\160A@@@\176'reduceU\144\160\160C@@@\176'toArray\144\160\160A@@@\176(forEachU\144\160\160B@@@\176(transfer\144\160\160B@@@\176)fromArray\144\160\160A@@@\176,popUndefined\144\160\160A@@@\176-peekUndefined\144\160\160A@@@A",
260260
(* Belt_MutableStack *)"\132\149\166\190\000\000\001\254\000\000\000\150\000\000\001\237\000\000\001\216\160\b\000\0008\000\176#pop\144\160\160A@@@\176#top\144\160\160A@@@\176$copy\144\160\160A@@\144\180A\160\176\001\003\246!s@@\151\176\177@\146\144$rootA\160\151\176\162@\160\004\006A\160\144\004\015@\176\192;others/belt_MutableStack.mlf\001\005\219\001\005\254\192\004\002f\001\005\219\001\006\004@@\176\192\004\004f\001\005\219\001\005\246\192\004\005f\001\005\219\001\006\005@\176$make\144\160\160A@@\144\180A\160\176\001\003\242%param@@\151\176\177@\146\144\004\030A\160\146A@\176\192\004\024b\001\005\159\001\005\173\192\004\025b\001\005\159\001\005\186@\176$push\144\160\160B@@@\176$size\144\160\160A@@@\176%clear\144\160\160A@@\144\180A\160\176\001\003\244!s@@\151\176\163@\144\004;\160\144\004\b\160\146A@\176\192\0047d\001\005\188\001\005\203\192\0048d\001\005\188\001\005\217@\176'forEach\144\160\160B@@@\176'isEmpty\144\160\160A@@\144\180A\160\176\001\004a!s@@\151\176\152@\160\151\176\162@\160\004YA\160\144\004\012@\176\192\004Su\001\007\014\001\007\030\192\004Tu\001\007\014\001\007$@\160\146A@\176\004\005\192\004Xu\001\007\014\001\007+@\176(forEachU\144\160\160B@@@\176,popUndefined\144\160\160A@@@\176,topUndefined\144\160\160A@@@\176.dynamicPopIter\144\160\160B@@@\176/dynamicPopIterU\144\160\160B@@@A",
261261
(* Belt_SortArrayInt *)"\132\149\166\190\000\000\000\164\000\000\000*\000\000\000\144\000\000\000\132\160\b\000\000 \000\176$diff\144\160\160H@@@\176%union\144\160\160H@@@\176(isSorted\144\160\160A@@@\176)intersect\144\160\160H@@@\176*stableSort\144\160\160A@@@\176,binarySearch\144\160\160B@@@\1761stableSortInPlace\144\160\160A@@@\1764strictlySortedLength\144\160\160A@@@A",
262262
(* Js_null_undefined *)"\132\149\166\190\000\000\000>\000\000\000\020\000\000\000@\000\000\000<\160\192\176$bind\144\160\160B@@@\176$iter\144\160\160B@@@\176(from_opt\144\160\160A@@@\176*fromOption\144\004\005@A",

jscomp/test/belt_internal_test.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ function copy(n) {
1313
if (n === undefined) {
1414
return n;
1515
}
16-
var match = n;
17-
var v = match.value;
18-
var h = match.height;
19-
var l = match.left;
20-
var r = match.right;
16+
var v = n.value;
17+
var h = n.height;
18+
var l = n.left;
19+
var r = n.right;
2120
return {
2221
value: v,
2322
height: h,

0 commit comments

Comments
 (0)