summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@typesafe.com>2014-11-11 09:43:21 +0100
committerLukas Rytz <lukas.rytz@typesafe.com>2014-11-11 09:43:21 +0100
commitd28d4f49088eb5e0809cbb68655319c68e981caa (patch)
tree2c59fc0f35b4e6ce89e68ff6ece261c4ef894f84 /src/library
parent0e8c6dac596279414dce576aa9f88289aa582fcc (diff)
parent59438d0647995f75bd1bf7159a248340d3708abd (diff)
downloadscala-d28d4f49088eb5e0809cbb68655319c68e981caa.tar.gz
scala-d28d4f49088eb5e0809cbb68655319c68e981caa.tar.bz2
scala-d28d4f49088eb5e0809cbb68655319c68e981caa.zip
Merge pull request #3963 from erikerlandson/si-8835-pr
SI-8835 Fix implementation of Iterator drop to remove quadratic behavior
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/collection/Iterator.scala9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala
index 660cc5a42a..0115cc154c 100644
--- a/src/library/scala/collection/Iterator.scala
+++ b/src/library/scala/collection/Iterator.scala
@@ -320,7 +320,14 @@ trait Iterator[+A] extends TraversableOnce[A] {
* it omits the first `n` values.
* @note Reuse: $consumesAndProducesIterator
*/
- def drop(n: Int): Iterator[A] = slice(n, Int.MaxValue)
+ def drop(n: Int): Iterator[A] = {
+ var j = 0
+ while (j < n && this.hasNext) {
+ this.next
+ j += 1
+ }
+ this
+ }
/** Creates an iterator returning an interval of the values produced by this iterator.
*