Skip to content

Commit

Permalink
Remove Size Check Optimization
Browse files Browse the repository at this point in the history
It makes the code confusing, and it is _possible_ that someone is using an implementation of SortedMap which doesn't have a precomputed size.
  • Loading branch information
David Strawn committed Dec 21, 2021
1 parent b09275b commit fc1fe42
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,7 @@ private[instances] class SortedMapOrder[K, V](implicit K: Order[K], V: Order[V])
if (x eq y) {
0
} else {
x.size.compare(y.size) match {
case 0 =>
StaticMethods.iteratorCompare(x.iterator, y.iterator)
case otherwise =>
otherwise
}
StaticMethods.iteratorCompare(x.iterator, y.iterator)
}
}

Expand All @@ -65,12 +60,7 @@ private[instances] class SortedMapPartialOrder[K, V](implicit K: PartialOrder[K]
if (x eq y) {
0.0
} else {
PartialOrder[Int].partialCompare(x.size, y.size) match {
case 0 =>
StaticMethods.iteratorPartialCompare(x.iterator, y.iterator)
case otherwise =>
otherwise
}
StaticMethods.iteratorPartialCompare(x.iterator, y.iterator)
}
}

Expand Down

0 comments on commit fc1fe42

Please sign in to comment.