diff options
author | Som Snytt <som.snytt@gmail.com> | 2016-12-30 11:33:48 -0800 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2016-12-30 11:33:48 -0800 |
commit | a75e4a7fafef9ce619a8d0f0622333d20502e7c8 (patch) | |
tree | 2896ba23de22ff2bbd56c91762ebeca5ca8887b2 /src/library | |
parent | bf9b00ebede9ab16fc4662a3dd5f5fb5d6a5ab7c (diff) | |
download | scala-a75e4a7fafef9ce619a8d0f0622333d20502e7c8.tar.gz scala-a75e4a7fafef9ce619a8d0f0622333d20502e7c8.tar.bz2 scala-a75e4a7fafef9ce619a8d0f0622333d20502e7c8.zip |
SI-9936 LinearSeqOptimized.indexWhere
Also suffered from the negative `from` bug.
Prefer `math.max` to avoid `RichInt`.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/IndexedSeqOptimized.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/LinearSeqOptimized.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/SeqLike.scala | 3 |
3 files changed, 3 insertions, 4 deletions
diff --git a/src/library/scala/collection/IndexedSeqOptimized.scala b/src/library/scala/collection/IndexedSeqOptimized.scala index 3765b2fff0..320725c30e 100644 --- a/src/library/scala/collection/IndexedSeqOptimized.scala +++ b/src/library/scala/collection/IndexedSeqOptimized.scala @@ -199,7 +199,7 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] { override /*SeqLike*/ def indexWhere(p: A => Boolean, from: Int): Int = { - val start = from max 0 + val start = math.max(from, 0) negLength(start + segmentLength(!p(_), start)) } diff --git a/src/library/scala/collection/LinearSeqOptimized.scala b/src/library/scala/collection/LinearSeqOptimized.scala index a3860f10a4..68b85dcfe5 100644 --- a/src/library/scala/collection/LinearSeqOptimized.scala +++ b/src/library/scala/collection/LinearSeqOptimized.scala @@ -291,7 +291,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea override /*SeqLike*/ def indexWhere(p: A => Boolean, from: Int): Int = { - var i = from + var i = math.max(from, 0) var these = this drop from while (these.nonEmpty) { if (p(these.head)) diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index 2d662257e5..3e025bc43f 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -113,13 +113,12 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ } def indexWhere(p: A => Boolean, from: Int): Int = { - var i = from max 0 + var i = math.max(from, 0) val it = iterator.drop(from) while (it.hasNext) { if (p(it.next())) return i else i += 1 } - -1 } |