Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 15a5379

Browse files
TIHannosami
authored andcommitted
Use for..in..do instead of List.iter to prevent function allocations (dotnet#8175)
1 parent 81e0b8f commit 15a5379

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/fsharp/PostInferenceChecks.fs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,14 @@ let rec CheckTypeDeep (cenv: cenv) ((visitTy, visitTyconRefOpt, visitAppTyOpt, v
322322
// In an ideal world we would, instead, record the solutions to these constraints as "witness variables" in expressions,
323323
// rather than solely in types.
324324
match ty with
325-
| TType_var tp when tp.Solution.IsSome ->
326-
tp.Constraints |> List.iter (fun cx ->
325+
| TType_var tp when tp.Solution.IsSome ->
326+
for cx in tp.Constraints do
327327
match cx with
328328
| TyparConstraint.MayResolveMember((TTrait(_, _, _, _, _, soln)), _) ->
329329
match visitTraitSolutionOpt, !soln with
330330
| Some visitTraitSolution, Some sln -> visitTraitSolution sln
331331
| _ -> ()
332-
| _ -> ())
332+
| _ -> ()
333333
| _ -> ()
334334

335335
let ty =
@@ -379,10 +379,12 @@ let rec CheckTypeDeep (cenv: cenv) ((visitTy, visitTyconRefOpt, visitAppTyOpt, v
379379
visitTyar (env, tp)
380380

381381
and CheckTypesDeep cenv f g env tys =
382-
tys |> List.iter (CheckTypeDeep cenv f g env true)
382+
for ty in tys do
383+
CheckTypeDeep cenv f g env true ty
383384

384385
and CheckTypesDeepNoInner cenv f g env tys =
385-
tys |> List.iter (CheckTypeDeep cenv f g env false)
386+
for ty in tys do
387+
CheckTypeDeep cenv f g env false ty
386388

387389
and CheckTypeConstraintDeep cenv f g env x =
388390
match x with

0 commit comments

Comments
 (0)