Skip to content

Commit

Permalink
Use .void over .map(_ => ()) to give instances chance to optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
TimWSpence committed Aug 25, 2023
1 parent 5c5049f commit a1c9ff5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/Traverse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,11 @@ object Traverse {
val iter = fa.iterator
if (iter.hasNext) {
val first = iter.next()
G.map(iter.foldLeft(f(first)) { case (g, a) =>
G.void(iter.foldLeft(f(first)) { case (g, a) =>
G.flatMap(g) { _ =>
f(a)
}
})(_ => ())
})
} else G.unit
}

Expand Down

0 comments on commit a1c9ff5

Please sign in to comment.