diff options
Diffstat (limited to 'src')
3 files changed, 6 insertions, 29 deletions
diff --git a/src/library/scala/collection/generic/LinearSequenceTemplate.scala b/src/library/scala/collection/generic/LinearSequenceTemplate.scala index 285170f63d..5a66f4cfa5 100644 --- a/src/library/scala/collection/generic/LinearSequenceTemplate.scala +++ b/src/library/scala/collection/generic/LinearSequenceTemplate.scala @@ -361,15 +361,7 @@ trait LinearSequenceTemplate[+A, +This <: LinearSequenceTemplate[A, This] with L } override def equals(that: Any): Boolean = that match { - case that1: LinearSequence[a] => - var these = this - var those = that1 - while (!these.isEmpty && !those.isEmpty && these.head == those.head) { - these = these.tail - those = those.tail - } - these.isEmpty && those.isEmpty - case _ => - super.equals(that) + case that: LinearSequence[_] => this sameElements that + case _ => super.equals(that) } } diff --git a/src/library/scala/collection/generic/SequenceTemplate.scala b/src/library/scala/collection/generic/SequenceTemplate.scala index 6696ca9e8c..0b210dd3f5 100644 --- a/src/library/scala/collection/generic/SequenceTemplate.scala +++ b/src/library/scala/collection/generic/SequenceTemplate.scala @@ -569,16 +569,8 @@ trait SequenceTemplate[+A, +This <: IterableTemplate[A, This] with Sequence[A]] } override def equals(that: Any): Boolean = that match { - case that1: Sequence[a] => - val these = this.iterator - val those = that1.iterator - while (these.hasNext && those.hasNext) - if (these.next() != those.next()) - return false - - !these.hasNext && !those.hasNext - case _ => - false + case that: Sequence[_] => this sameElements that + case _ => false } /** Need to override string, so that it's not the Function1's string that gets mixed in. diff --git a/src/library/scala/collection/generic/VectorTemplate.scala b/src/library/scala/collection/generic/VectorTemplate.scala index 96e80276b8..daba1709cd 100644 --- a/src/library/scala/collection/generic/VectorTemplate.scala +++ b/src/library/scala/collection/generic/VectorTemplate.scala @@ -258,15 +258,8 @@ trait VectorTemplate[+A, +This <: VectorTemplate[A, This] with Vector[A]] extend } override def equals(that: Any): Boolean = that match { - case that1: Vector[a] => - val len = this.length - len == that1.length && { - var i = 0 - while (i < len && this(i) == that1(i)) i += 1 - i == len - } - case _ => - super.equals(that) + case that: Vector[_] => this.length == that.length && startsWith(that, 0) + case _ => super.equals(that) } override def view = new VectorView[A, This] { |