Skip to content

Commit

Permalink
Let's see
Browse files Browse the repository at this point in the history
  • Loading branch information
brianrourkeboll committed Jan 25, 2024
1 parent 0136a96 commit 9b26084
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/Compiler/Optimize/LowerComputedCollections.fs
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,16 @@ let LowerComputedListOrArrayExpr tcVal (g: TcGlobals) amap overallExpr =
->
Some (ComputedCollectionExprLowering.Expr (mkUnionCaseExpr (g.nil_ucref, [g.int32_ty], [], m)))

// [1..5] → [1; 2; 3; 4; 5] ≡ 1 :: 2 :: 3 :: 4 :: 5 :: []
| SeqToList g (OptionalCoerce (OptionalSeq g amap (ConstInt32Range g (start, finish))), _) when
finish - start < constListSizeThreshold
->
// … :: … :: …
let rec conses acc n =
if n < start then acc
else conses (mkCons g g.int32_ty (Expr.Const (Const.Int32 n, Text.Range.range0, g.int32_ty)) acc) (n - 1)
//// [1..5] → [1; 2; 3; 4; 5] ≡ 1 :: 2 :: 3 :: 4 :: 5 :: []
//| SeqToList g (OptionalCoerce (OptionalSeq g amap (ConstInt32Range g (start, finish))), _) when
// finish - start < constListSizeThreshold
// ->
// // … :: … :: …
// let rec conses acc n =
// if n < start then acc
// else conses (mkCons g g.int32_ty (Expr.Const (Const.Int32 n, Text.Range.range0, g.int32_ty)) acc) (n - 1)

Some (ComputedCollectionExprLowering.Expr (conses (mkNil g Text.Range.range0 g.int32_ty) finish))
// Some (ComputedCollectionExprLowering.Expr (conses (mkNil g Text.Range.range0 g.int32_ty) finish))

// [start..finish] → if start <= finish then List.init (finish - start + 1) ((+) start) else []
| SeqToList g (OptionalCoerce (OptionalSeq g amap (Int32Range g (start, finish))), m) ->
Expand Down Expand Up @@ -324,11 +324,11 @@ let LowerComputedListOrArrayExpr tcVal (g: TcGlobals) amap overallExpr =
->
Some (ComputedCollectionExprLowering.Expr (mkArray (g.int32_ty, [], m)))

// [|1..5|] → [|1; 2; 3; 4; 5|]
| SeqToArray g (OptionalCoerce (OptionalSeq g amap (ConstInt32Range g (start, finish))), m) when
(finish - start) * sizeof<int32> < constArrayBytesThreshold
->
Some (ComputedCollectionExprLowering.Expr (mkArray (g.int32_ty, [for n in start..finish -> Expr.Const (Const.Int32 n, Text.Range.range0, g.int32_ty)], m)))
//// [|1..5|] → [|1; 2; 3; 4; 5|]
//| SeqToArray g (OptionalCoerce (OptionalSeq g amap (ConstInt32Range g (start, finish))), m) when
// (finish - start) * sizeof<int32> < constArrayBytesThreshold
// ->
// Some (ComputedCollectionExprLowering.Expr (mkArray (g.int32_ty, [for n in start..finish -> Expr.Const (Const.Int32 n, Text.Range.range0, g.int32_ty)], m)))

// [|start..finish|] → if start <= finish then Array.init (finish - start + 1) ((+) start) else [||]
| SeqToArray g (OptionalCoerce (OptionalSeq g amap (Int32Range g (start, finish))), m) ->
Expand Down

0 comments on commit 9b26084

Please sign in to comment.