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

minor IL simplification (#3975)

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