提交 d8544fe2 编写于 作者: N ncave 提交者: Kevin Ransom (msft)

minor IL simplification (#3975)

上级 e0596f3a
......@@ -212,15 +212,11 @@ namespace Microsoft.FSharp.Collections
[<CompiledName("Fold")>]
let fold<'T,'State> folder (state:'State) (list: 'T list) =
match list with
| [] -> state
| _ ->
let f = OptimizedClosures.FSharpFunc<_,_,_>.Adapt(folder)
let rec loop s xs =
match xs with
| [] -> s
| h::t -> loop (f.Invoke(s,h)) t
loop state list
let f = OptimizedClosures.FSharpFunc<_,_,_>.Adapt(folder)
let mutable acc = state
for x in list do
acc <- f.Invoke(acc, x)
acc
[<CompiledName("Pairwise")>]
let pairwise (list: 'T list) =
......@@ -356,12 +352,10 @@ namespace Microsoft.FSharp.Collections
let exists predicate list = Microsoft.FSharp.Primitives.Basics.List.exists predicate list
[<CompiledName("Contains")>]
let inline contains value source =
let rec contains e xs1 =
match xs1 with
| [] -> false
| h1::t1 -> e = h1 || contains e t1
contains value source
let rec contains value source =
match source with
| [] -> false
| h::t -> if h = value then true else contains value t
let rec exists2aux (f:OptimizedClosures.FSharpFunc<_,_,_>) list1 list2 =
match list1,list2 with
......
......@@ -102,7 +102,7 @@ namespace Microsoft.FSharp.Collections
/// <param name="source">The input list.</param>
/// <returns>True if the input list contains the specified element; false otherwise.</returns>
[<CompiledName("Contains")>]
val inline contains: value:'T -> source:'T list -> bool when 'T : equality
val contains: value:'T -> source:'T list -> bool when 'T : equality
/// <summary>Returns a list that contains no duplicate entries according to generic hash and
/// equality comparisons on the entries.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册