diff options
author | Paul Phillips <paulp@improving.org> | 2010-01-20 00:28:09 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-01-20 00:28:09 +0000 |
commit | 10ee5fd9cef30afa576808cbead4dc57952c13f4 (patch) | |
tree | 40a1f9718fae039d793fb2ec15bf3dd91377888b /src/library/scala/collection/SeqLike.scala | |
parent | 08013877acb1155fa46398988efaa2cab21f78ae (diff) | |
download | scala-10ee5fd9cef30afa576808cbead4dc57952c13f4.tar.gz scala-10ee5fd9cef30afa576808cbead4dc57952c13f4.tar.bz2 scala-10ee5fd9cef30afa576808cbead4dc57952c13f4.zip |
Fix for #2927. No review.
Diffstat (limited to 'src/library/scala/collection/SeqLike.scala')
-rw-r--r-- | src/library/scala/collection/SeqLike.scala | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index 32aae28851..9802f63fa2 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -261,9 +261,12 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] { self => def indexWhere(p: A => Boolean, from: Int): Int = { var i = from var it = iterator.drop(from) - while (it.hasNext && !p(it.next())) - i += 1 - if (it.hasNext) i else -1 + while (it.hasNext) { + if (p(it.next())) return i + else i += 1 + } + + -1 } /** Returns index of the first element satisying a predicate, or `-1`. @@ -721,7 +724,7 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] { self => b ++= thisCollection while (diff > 0) { b += elem - diff -=1 + diff -= 1 } b.result } @@ -839,8 +842,8 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] { self => override def hashCode() = (Seq.hashSeed /: this)(_ * 41 + _.hashCode) override def equals(that: Any): Boolean = that match { - case that: Seq[_] => (that canEqual this) && (this sameElements that) - case _ => false + case that: Seq[_] => (that canEqual this) && (this sameElements that) + case _ => false } /* Need to override string, so that it's not the Function1's string that gets mixed in. |