summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/Iterator.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-04-20 20:43:37 +0000
committerPaul Phillips <paulp@improving.org>2011-04-20 20:43:37 +0000
commit21ea5ad62747504e2c17c10c779e5c7054a2a297 (patch)
tree8e3d4ac052ffd406d179da2694a9fd93724a4e13 /src/library/scala/collection/Iterator.scala
parent9be2e5463396e4a5022745c9d61a8431d53e2f99 (diff)
downloadscala-21ea5ad62747504e2c17c10c779e5c7054a2a297.tar.gz
scala-21ea5ad62747504e2c17c10c779e5c7054a2a297.tar.bz2
scala-21ea5ad62747504e2c17c10c779e5c7054a2a297.zip
One of the blips in the performance charts seem...
One of the blips in the performance charts seems to implicate some changes I made with slice to reduce the number of implementations and surface area for inconsistencies and bugs. Altering those changes in a more performance-mindful way, although I don't see anything here which is likely to help much. Also fixing some wrong documentation about copyToArray. No review.
Diffstat (limited to 'src/library/scala/collection/Iterator.scala')
-rw-r--r--src/library/scala/collection/Iterator.scala7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala
index 7bd33cbb23..39c1d5b07f 100644
--- a/src/library/scala/collection/Iterator.scala
+++ b/src/library/scala/collection/Iterator.scala
@@ -975,8 +975,8 @@ trait Iterator[+A] extends TraversableOnce[A] {
}
/** Copies selected values produced by this iterator to an array.
- * Fills the given array `xs` with at most `len` values produced by this
- * iterator, after skipping `start` values.
+ * Fills the given array `xs` starting at index `start` with at most
+ * `len` values produced by this iterator.
* Copying will stop once either the end of the current iterator is reached,
* or the end of the array is reached, or `len` elements have been copied.
*
@@ -987,12 +987,11 @@ trait Iterator[+A] extends TraversableOnce[A] {
* @param len the maximal number of elements to copy.
* @tparam B the type of the elements of the array.
*
- *
* @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
*/
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit = {
var i = start
- val end = start + len min xs.length
+ val end = start + math.min(len, xs.length)
while (hasNext && i < end) {
xs(i) = next()
i += 1