Skip to content

Commit 9ef05a7

Browse files
ncaveKevinRansom
authored andcommitted
List.fold IL simplification (#3982)
1 parent 4afe7a5 commit 9ef05a7

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/fsharp/FSharp.Core/list.fs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,10 @@ namespace Microsoft.FSharp.Collections
216216
| [] -> state
217217
| _ ->
218218
let f = OptimizedClosures.FSharpFunc<_,_,_>.Adapt(folder)
219-
let rec loop s xs =
220-
match xs with
221-
| [] -> s
222-
| h::t -> loop (f.Invoke(s,h)) t
223-
loop state list
219+
let mutable acc = state
220+
for x in list do
221+
acc <- f.Invoke(acc, x)
222+
acc
224223

225224
[<CompiledName("Pairwise")>]
226225
let pairwise (list: 'T list) =

0 commit comments

Comments
 (0)