Skip to content

Commit

Permalink
small optimisation for optF
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil Hotkowski committed Aug 3, 2022
1 parent fd87685 commit 0cd6d46
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/src/main/scala/cats/TraverseFilter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ trait TraverseFilter[F[_]] extends FunctorFilter[F] {
* scala> result.value
* res0: List[Option[String]] = List(Some(two), None)
*/
def traverseCollect[G[_], A, B](fa: F[A])(f: PartialFunction[A, G[B]])(implicit G: Applicative[G]): G[F[B]] =
traverseFilter(fa)(a => Traverse[Option].sequence(f.lift(a)))
def traverseCollect[G[_], A, B](fa: F[A])(f: PartialFunction[A, G[B]])(implicit G: Applicative[G]): G[F[B]] = {
val optF = f.lift
traverseFilter(fa)(a => Traverse[Option].sequence(optF(a)))
}

/**
* {{{
Expand Down

0 comments on commit 0cd6d46

Please sign in to comment.