Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use for..in..do instead of List.iter to prevent function allocations #8175

Merged
merged 1 commit into from Jan 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/fsharp/PostInferenceChecks.fs
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