Skip to content

Commit

Permalink
Use ArraySeq.untagged instead of ClassTag[Nothing]
Browse files Browse the repository at this point in the history
  • Loading branch information
travisbrown committed Feb 26, 2020
1 parent 2e12f4d commit 13fd9e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/main/scala-2.13+/cats/instances/arraySeq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ private[cats] object ArraySeqInstances {
}

override def map2[A, B, Z](fa: ArraySeq[A], fb: ArraySeq[B])(f: (A, B) => Z): ArraySeq[Z] =
if (fb.isEmpty) ArraySeq.empty // do O(1) work if fb is empty
if (fb.isEmpty) ArraySeq.untagged.empty // do O(1) work if fb is empty
else fa.flatMap(a => fb.map(b => f(a, b))) // already O(1) if fa is empty

override def map2Eval[A, B, Z](fa: ArraySeq[A], fb: Eval[ArraySeq[B]])(f: (A, B) => Z): Eval[ArraySeq[Z]] =
if (fa.isEmpty) Eval.now(ArraySeq.empty) // no need to evaluate fb
if (fa.isEmpty) Eval.now(ArraySeq.untagged.empty) // no need to evaluate fb
else fb.map(fb => map2(fa, fb)(f))

def foldLeft[A, B](fa: ArraySeq[A], b: B)(f: (B, A) => B): B =
Expand Down

0 comments on commit 13fd9e5

Please sign in to comment.