Skip to content

Commit

Permalink
Use for..in..do instead of List.iter to prevent function allocations (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
TIHan authored and nosami committed Feb 22, 2021
1 parent 81e0b8f commit 15a5379
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/fsharp/PostInferenceChecks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,14 @@ let rec CheckTypeDeep (cenv: cenv) ((visitTy, visitTyconRefOpt, visitAppTyOpt, v
// In an ideal world we would, instead, record the solutions to these constraints as "witness variables" in expressions,
// rather than solely in types.
match ty with
| TType_var tp when tp.Solution.IsSome ->
tp.Constraints |> List.iter (fun cx ->
| TType_var tp when tp.Solution.IsSome ->
for cx in tp.Constraints do
match cx with
| TyparConstraint.MayResolveMember((TTrait(_, _, _, _, _, soln)), _) ->
match visitTraitSolutionOpt, !soln with
| Some visitTraitSolution, Some sln -> visitTraitSolution sln
| _ -> ()
| _ -> ())
| _ -> ()
| _ -> ()

let ty =
Expand Down Expand Up @@ -379,10 +379,12 @@ let rec CheckTypeDeep (cenv: cenv) ((visitTy, visitTyconRefOpt, visitAppTyOpt, v
visitTyar (env, tp)

and CheckTypesDeep cenv f g env tys =
tys |> List.iter (CheckTypeDeep cenv f g env true)
for ty in tys do
CheckTypeDeep cenv f g env true ty

and CheckTypesDeepNoInner cenv f g env tys =
tys |> List.iter (CheckTypeDeep cenv f g env false)
for ty in tys do
CheckTypeDeep cenv f g env false ty

and CheckTypeConstraintDeep cenv f g env x =
match x with
Expand Down

0 comments on commit 15a5379

Please sign in to comment.