From 411bad2dd62006c78a2f7e9055572b65d3d32123 Mon Sep 17 00:00:00 2001 From: Will Smith Date: Sun, 12 Jan 2020 05:08:31 -0800 Subject: [PATCH] Use for..in..do instead of List.iter to prevent function allocations --- src/fsharp/PostInferenceChecks.fs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/fsharp/PostInferenceChecks.fs b/src/fsharp/PostInferenceChecks.fs index 1730f88bd2c..2420e636d24 100644 --- a/src/fsharp/PostInferenceChecks.fs +++ b/src/fsharp/PostInferenceChecks.fs @@ -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 = @@ -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