@@ -2179,9 +2179,8 @@ module Array =
21792179 // Not exists $condition <==> (opposite of $condition is true forall)
21802180 exists ( predicate >> not ) array |> not
21812181
2182- [<CompiledName( " TryFindIndex" ) >]
2183- let tryFindIndex predicate ( array : _ array ) =
2184- checkNonNull " array" array
2182+ let inline tryFindIndexAux predicate ( array : _ array ) =
2183+ checkNonNull ( nameof array) array
21852184
21862185 let pResult =
21872186 Parallel.For(
@@ -2192,16 +2191,24 @@ module Array =
21922191 pState.Break())
21932192 )
21942193
2195- pResult.LowestBreakIteration |> Option.ofNullable |> Option.map int
2194+ pResult.LowestBreakIteration
2195+
2196+ [<CompiledName( " TryFindIndex" ) >]
2197+ let tryFindIndex predicate ( array : _ array ) =
2198+ let i = tryFindIndexAux predicate array
2199+ if i.HasValue then Some ( int ( i.GetValueOrDefault()))
2200+ else None
21962201
21972202 [<CompiledName( " TryFind" ) >]
21982203 let tryFind predicate ( array : _ array ) =
2199- array |> tryFindIndex predicate |> Option.map ( fun i -> array[ i])
2204+ let i = tryFindIndexAux predicate array
2205+ if i.HasValue then Some array[ int ( i.GetValueOrDefault())]
2206+ else None
22002207
22012208 [<CompiledName( " TryPick" ) >]
22022209 let tryPick chooser ( array : _ array ) =
22032210 checkNonNull " array" array
2204- let allChosen = new System.Collections.Concurrent.ConcurrentDictionary<_, _> ()
2211+ let allChosen = System.Collections.Concurrent.ConcurrentDictionary()
22052212
22062213 let pResult =
22072214 Parallel.For(
@@ -2215,9 +2222,8 @@ module Array =
22152222 pState.Break())
22162223 )
22172224
2218- pResult.LowestBreakIteration
2219- |> Option.ofNullable
2220- |> Option.bind ( fun i -> allChosen[ int i])
2225+ if pResult.LowestBreakIteration.HasValue then allChosen[ int ( pResult.LowestBreakIteration.GetValueOrDefault())]
2226+ else None
22212227
22222228 [<CompiledName( " Choose" ) >]
22232229 let choose chooser ( array : 'T array ) =
0 commit comments