Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd8544fe

Browse files
ncaveKevinRansom
authored andcommitted
minor IL simplification (dotnet#3975)
1 parente0596f3 commitd8544fe

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

‎src/fsharp/FSharp.Core/list.fs‎

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,11 @@ namespace Microsoft.FSharp.Collections
212212

213213
[<CompiledName("Fold")>]
214214
letfold<'T,'State>folder(state:'State)(list:'T list)=
215-
match listwith
216-
|[]-> state
217-
|_->
218-
letf= OptimizedClosures.FSharpFunc<_,_,_>.Adapt(folder)
219-
let recloop s xs=
220-
match xswith
221-
|[]-> s
222-
| h::t-> loop(f.Invoke(s,h)) t
223-
loop state list
215+
letf= OptimizedClosures.FSharpFunc<_,_,_>.Adapt(folder)
216+
let mutableacc= state
217+
for xin listdo
218+
acc<- f.Invoke(acc, x)
219+
acc
224220

225221
[<CompiledName("Pairwise")>]
226222
letpairwise(list:'T list)=
@@ -356,12 +352,10 @@ namespace Microsoft.FSharp.Collections
356352
letexists predicate list= Microsoft.FSharp.Primitives.Basics.List.exists predicate list
357353

358354
[<CompiledName("Contains")>]
359-
let inlinecontains value source=
360-
let reccontains e xs1=
361-
match xs1with
362-
|[]->false
363-
| h1::t1-> e= h1|| contains e t1
364-
contains value source
355+
let reccontains value source=
356+
match sourcewith
357+
|[]->false
358+
| h::t->if h= valuethentrueelse contains value t
365359

366360
let recexists2aux(f:OptimizedClosures.FSharpFunc<_,_,_>)list1 list2=
367361
match list1,list2with

‎src/fsharp/FSharp.Core/list.fsi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ namespace Microsoft.FSharp.Collections
102102
///<param name="source">The input list.</param>
103103
///<returns>True if the input list contains the specified element;false otherwise.</returns>
104104
[<CompiledName("Contains")>]
105-
valinlinecontains:value:'T->source:'T list->bool when 'T:equality
105+
val contains:value:'T->source:'T list->bool when 'T:equality
106106

107107
///<summary>Returns a list that contains no duplicate entries according to generic hash and
108108
///equality comparisons on the entries.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp