Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ArraySeq.untagged instead of ClassTag[Nothing] #3324

Merged
merged 1 commit into from
Feb 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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