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

Commita7a6586

Browse files
authored
Revert "minor IL simplification (#3975)" (#3979)
This reverts commitd8544fe.
1 parentd8544fe commita7a6586

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

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

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

213213
[<CompiledName("Fold")>]
214214
letfold<'T,'State>folder(state:'State)(list:'T list)=
215-
letf= OptimizedClosures.FSharpFunc<_,_,_>.Adapt(folder)
216-
let mutableacc= state
217-
for xin listdo
218-
acc<- f.Invoke(acc, x)
219-
acc
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
220224

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

354358
[<CompiledName("Contains")>]
355-
let reccontains value source=
356-
match sourcewith
357-
|[]->false
358-
| h::t->if h= valuethentrueelse contains value t
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
359365

360366
let recexists2aux(f:OptimizedClosures.FSharpFunc<_,_,_>)list1 list2=
361367
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-
val contains:value:'T->source:'T list->bool when 'T:equality
105+
valinlinecontains: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