diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-02-19 10:25:00 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-02-19 10:25:00 -0800 |
commit | 2d26cacd24b396c7f7449e731f059811d0d1fac4 (patch) | |
tree | ee042e7b60f9c007ed3084a5a4833237c2dec6a4 /src/library | |
parent | d93fc01d58f4b2f20cd4d631d1a72fcd0e1aa438 (diff) | |
parent | ad7a2f2d497c59eb61284447b38ea2697f9ab738 (diff) | |
download | scala-2d26cacd24b396c7f7449e731f059811d0d1fac4.tar.gz scala-2d26cacd24b396c7f7449e731f059811d0d1fac4.tar.bz2 scala-2d26cacd24b396c7f7449e731f059811d0d1fac4.zip |
Merge pull request #4337 from Ichoran/opt-IterLike-2.11.x
Optimization of IterableLike.scala
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/IterableLike.scala | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/library/scala/collection/IterableLike.scala b/src/library/scala/collection/IterableLike.scala index 7643b84a8b..ecf64624e8 100644 --- a/src/library/scala/collection/IterableLike.scala +++ b/src/library/scala/collection/IterableLike.scala @@ -218,12 +218,12 @@ self => val b = newBuilder b.sizeHintBounded(n, this) val lead = this.iterator drop n - var go = false - for (x <- this) { - if (lead.hasNext) lead.next() - else go = true - if (go) b += x + val it = this.iterator + while (lead.hasNext) { + lead.next() + it.next() } + while (it.hasNext) b += it.next() b.result() } @@ -283,7 +283,7 @@ self => var i = 0 for (x <- this) { b += ((x, i)) - i +=1 + i += 1 } b.result() } |