Skip to content

Commit e7d09b2

Browse files
forkiKevinRansom
authored andcommitted
Use List.exists for contains (#1518)
* Use List.exists for contains * ListSet.contains is List.exists * Revert "ListSet.contains is List.exists" This reverts commit dc41206f8ffd4ef047ade0eaf1ae200900609b11.
1 parent b6785c8 commit e7d09b2

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/fsharp/autobox.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ open Microsoft.FSharp.Compiler.TypeRelations
1717
// Decide the set of mutable locals to promote to heap-allocated reference cells
1818

1919
type cenv =
20-
{ g: TcGlobals;
20+
{ g: TcGlobals
2121
amap: Import.ImportMap }
2222

2323
/// Find all the mutable locals that escape a method, function or lambda expression

src/fsharp/lib.fs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,11 @@ module ListAssoc =
178178
//------------------------------------------------------------------------
179179

180180
module ListSet =
181-
(* NOTE: O(n)! *)
182-
let rec contains f x l =
183-
match l with
184-
| [] -> false
185-
| x'::t -> f x x' || contains f x t
181+
let inline contains f x l = List.exists (f x) l
186182

187183
(* NOTE: O(n)! *)
188184
let insert f x l = if contains f x l then l else x::l
185+
189186
let unionFavourRight f l1 l2 =
190187
match l1, l2 with
191188
| _, [] -> l1

0 commit comments

Comments
 (0)