Skip to content

Commit

Permalink
Remove optimized combineAll
Browse files Browse the repository at this point in the history
  • Loading branch information
Luka Jacobowitz committed Oct 16, 2017
1 parent fef41c1 commit c226af6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
12 changes: 0 additions & 12 deletions core/src/main/scala/cats/instances/sortedMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import cats.kernel.instances.StaticMethods

import scala.annotation.tailrec
import scala.collection.immutable.SortedMap
import scala.collection.mutable

trait SortedMapInstances extends SortedMapInstances1 {

Expand Down Expand Up @@ -159,15 +158,4 @@ class SortedMapMonoid[K, V](implicit V: Semigroup[V], O: Order[K]) extends Monoi
}
}

override def combineAll(xss: TraversableOnce[SortedMap[K, V]]): SortedMap[K, V] = {
val acc = mutable.SortedMap.empty[K, V](O.toOrdering)
xss.foreach { m =>
val it = m.iterator
while (it.hasNext) {
val (k, v) = it.next
acc(k) = Semigroup.maybeCombine(acc.get(k), v)
}
}
SortedMap.empty[K, V](O.toOrdering) ++ acc
}
}
6 changes: 3 additions & 3 deletions tests/src/test/scala/cats/tests/SortedMapTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SortedMapTests extends CatsSuite {
}
}

checkAll("Hash[Map[Int, String]]" , HashLawTests[Map[Int, String]].hash)
checkAll("Monoid[Map[String, Int]]", MonoidLawTests[Map[String, Int]].monoid)
checkAll("Monoid[Map[String, Int]]", SerializableTests.serializable(Monoid[Map[String, Int]]))
checkAll("Hash[SortedMap[Int, String]]" , HashLawTests[SortedMap[Int, String]].hash)
checkAll("Monoid[SortedMap[String, Int]]", MonoidLawTests[SortedMap[String, Int]].monoid)
checkAll("Monoid[SortedMap[String, Int]]", SerializableTests.serializable(Monoid[SortedMap[String, Int]]))
}

0 comments on commit c226af6

Please sign in to comment.