@@ -932,36 +932,24 @@ module Util =
932932 // | Fable.NewList (headAndTail, _) when List.contains "FABLE_LIBRARY" com.Options.Define ->
933933 // makeList com ctx r headAndTail
934934 // Optimization for bundle size: compile list literals as List.ofArray
935- | Replacements.ListLiteral( exprs, t) ->
936- [| List.rev exprs |> makeArray com ctx|]
937- |> libCall com ctx r " List" " newList"
938- // match exprs with
939- // | [] -> libCall com ctx r "List" "empty" [||]
940- // | [TransformExpr com ctx expr] -> libCall com ctx r "List" "singleton" [|expr|]
941- // | exprs -> [|makeArray com ctx exprs|] |> libCall com ctx r "List" "ofArray"
942935 | Fable.NewList ( headAndTail, _) ->
943- match headAndTail with
944- | None -> libCall com ctx r " List" " empty" [||]
945- | Some( TransformExpr com ctx head, TransformExpr com ctx tail) ->
936+ let rec getItems acc = function
937+ | None -> List.rev acc, None
938+ | Some( head, Fable.Value( Fable.NewList( tail, _),_)) -> getItems ( head:: acc) tail
939+ | Some( head, tail) -> List.rev ( head:: acc), Some tail
940+ match getItems [] headAndTail with
941+ | [], None ->
942+ libCall com ctx r " List" " empty" [||]
943+ | [ TransformExpr com ctx expr], None ->
944+ libCall com ctx r " List" " singleton" [| expr|]
945+ | exprs, None ->
946+ [| List.rev exprs |> makeArray com ctx|]
947+ |> libCall com ctx r " List" " newList"
948+ | [ TransformExpr com ctx head], Some( TransformExpr com ctx tail) ->
946949 libCall com ctx r " List" " cons" [| head; tail|]
947-
948- // let rec getItems acc = function
949- // | None -> List.rev acc, None
950- // | Some(head, Fable.Value(Fable.NewList(tail, _),_)) -> getItems (head::acc) tail
951- // | Some(head, tail) -> List.rev (head::acc), Some tail
952- // match getItems [] headAndTail with
953- // | [], None ->
954- // libCall com ctx r "List" "empty" [||]
955- // | [TransformExpr com ctx expr], None ->
956- // libCall com ctx r "List" "singleton" [|expr|]
957- // | exprs, None ->
958- // [|makeArray com ctx exprs|]
959- // |> libCall com ctx r "List" "ofArray"
960- // | [TransformExpr com ctx head], Some(TransformExpr com ctx tail) ->
961- // libCall com ctx r "List" "cons" [|head; tail|]
962- // | exprs, Some(TransformExpr com ctx tail) ->
963- // [|makeArray com ctx exprs; tail|]
964- // |> libCall com ctx r "List" "ofArrayWithTail"
950+ | exprs, Some( TransformExpr com ctx tail) ->
951+ [| List.rev exprs |> makeArray com ctx; tail|]
952+ |> libCall com ctx r " List" " newListWithTail"
965953 | Fable.NewOption ( value, t) ->
966954 match value with
967955 | Some ( TransformExpr com ctx e) ->
@@ -1216,11 +1204,11 @@ module Util =
12161204
12171205 | Fable.ListHead ->
12181206 // get range (com.TransformAsExpr(ctx, fableExpr)) "head"
1219- libCall com ctx range " List" " head " [| com.TransformAsExpr( ctx, fableExpr)|]
1207+ libCall com ctx range " List" " head_ " [| com.TransformAsExpr( ctx, fableExpr)|]
12201208
12211209 | Fable.ListTail ->
12221210 // get range (com.TransformAsExpr(ctx, fableExpr)) "tail"
1223- libCall com ctx range " List" " tail " [| com.TransformAsExpr( ctx, fableExpr)|]
1211+ libCall com ctx range " List" " tail_ " [| com.TransformAsExpr( ctx, fableExpr)|]
12241212
12251213 | Fable.TupleIndex index ->
12261214 match fableExpr with
0 commit comments