Skip to content

Commit

Permalink
Merge pull request #3324 from travisbrown/topic/nothing-class-tags
Browse files Browse the repository at this point in the history
Use ArraySeq.untagged instead of ClassTag[Nothing]
  • Loading branch information
fthomas committed Feb 26, 2020
2 parents 469f1eb + 13fd9e5 commit 2573961
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 2573961

Please sign in to comment.