Skip to content

Commit

Permalink
optimized map method to include Wrap check (#2995)
Browse files Browse the repository at this point in the history
  • Loading branch information
gagandeepkalra authored and LukaJCB committed Aug 20, 2019
1 parent 241a7b9 commit a97bb9a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/src/main/scala/cats/data/Chain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ sealed abstract class Chain[+A] {
/**
* Applies the supplied function to each element and returns a new Chain.
*/
final def map[B](f: A => B): Chain[B] =
fromSeq(iterator.map(f).toVector)
final def map[B](f: A => B): Chain[B] = this match {
case Wrap(seq) => Wrap(seq.map(f))
case _ => fromSeq(iterator.map(f).toVector)
}

/**
* Applies the supplied function to each element and returns a new Chain from the concatenated results
Expand Down

0 comments on commit a97bb9a

Please sign in to comment.