Skip to content

Instantly share code, notes, and snippets.

@lrytz
Created June 22, 2020 10:15
Show Gist options
  • Save lrytz/abedbea45a43a407d12e7cde418cf55b to your computer and use it in GitHub Desktop.
Save lrytz/abedbea45a43a407d12e7cde418cf55b to your computer and use it in GitHub Desktop.
diff --git a/src/library/scala/collection/Map.scala b/src/library/scala/collection/Map.scala
index 9187c7c041..704a0f7f3e 100644
--- a/src/library/scala/collection/Map.scala
+++ b/src/library/scala/collection/Map.scala
@@ -33,7 +33,7 @@ trait Map[K, +V]
case that: Map[K, _] =>
(this eq that) ||
(that canEqual this) &&
- (this.size == that.size) && {
+ (this.sizeCompare(that) == 0) && {
try {
val checker = new AbstractFunction1[(K, V),Boolean] {
override def apply(kv: (K,V)): Boolean = {
diff --git a/src/library/scala/collection/Set.scala b/src/library/scala/collection/Set.scala
index d82117cc6a..daa004d8a1 100644
--- a/src/library/scala/collection/Set.scala
+++ b/src/library/scala/collection/Set.scala
@@ -31,7 +31,7 @@ trait Set[A]
case set: Set[A] =>
(this eq set) ||
(set canEqual this) &&
- (toIterable.size == set.size) &&
+ (toIterable.sizeCompare(set) == 0) &&
(this subsetOf set)
case _ => false
}
diff --git a/src/library/scala/collection/immutable/IntMap.scala b/src/library/scala/collection/immutable/IntMap.scala
index f9a8e4233f..47116e0fcf 100644
--- a/src/library/scala/collection/immutable/IntMap.scala
+++ b/src/library/scala/collection/immutable/IntMap.scala
@@ -261,7 +261,7 @@ sealed abstract class IntMap[+T] extends AbstractMap[Int, T]
override protected[this] def className = "IntMap"
- override def isEmpty = this == IntMap.Nil
+ override def isEmpty = this eq IntMap.Nil
override def knownSize: Int = if (isEmpty) 0 else super.knownSize
override def filter(f: ((Int, T)) => Boolean): IntMap[T] = this match {
case IntMap.Bin(prefix, mask, left, right) => {
diff --git a/src/library/scala/collection/immutable/LongMap.scala b/src/library/scala/collection/immutable/LongMap.scala
index 0d3524e600..d07b1277fe 100644
--- a/src/library/scala/collection/immutable/LongMap.scala
+++ b/src/library/scala/collection/immutable/LongMap.scala
@@ -256,7 +256,7 @@ sealed abstract class LongMap[+T] extends AbstractMap[Long, T]
override protected[this] def className = "LongMap"
- override def isEmpty = this == LongMap.Nil
+ override def isEmpty = this eq LongMap.Nil
override def knownSize: Int = if (isEmpty) 0 else super.knownSize
override def filter(f: ((Long, T)) => Boolean): LongMap[T] = this match {
case LongMap.Bin(prefix, mask, left, right) => {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment