summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/SeqLike.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-01-20 00:28:09 +0000
committerPaul Phillips <paulp@improving.org>2010-01-20 00:28:09 +0000
commit10ee5fd9cef30afa576808cbead4dc57952c13f4 (patch)
tree40a1f9718fae039d793fb2ec15bf3dd91377888b /src/library/scala/collection/SeqLike.scala
parent08013877acb1155fa46398988efaa2cab21f78ae (diff)
downloadscala-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.scala15
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.