summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-03-30 21:25:16 +0000
committerPaul Phillips <paulp@improving.org>2010-03-30 21:25:16 +0000
commite7e15da74c1c9a81f419b640c79c636e704b8ed5 (patch)
treec1bbb79db47b75cb915f9094d30e93cef260f84c /src/library
parent0e7403eea2e7082a255ad258c8d2a38c6156f476 (diff)
downloadscala-e7e15da74c1c9a81f419b640c79c636e704b8ed5.tar.gz
scala-e7e15da74c1c9a81f419b640c79c636e704b8ed5.tar.bz2
scala-e7e15da74c1c9a81f419b640c79c636e704b8ed5.zip
Noticed that the implementation of toArray Iter...
Noticed that the implementation of toArray Iterator had acquired via TraversableOnce called "size" to allocate the array, leaving a nice empty iterator to actually populate it. Fixed. No review.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/collection/TraversableOnce.scala9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala
index 2224f534ad..6e4917b77e 100644
--- a/src/library/scala/collection/TraversableOnce.scala
+++ b/src/library/scala/collection/TraversableOnce.scala
@@ -378,9 +378,12 @@ trait TraversableOnce[+A] {
* A `ClassManifest` must be available for the element type of this $coll.
*/
def toArray[B >: A : ClassManifest]: Array[B] = {
- val result = new Array[B](size)
- copyToArray(result, 0)
- result
+ if (isTraversableAgain) {
+ val result = new Array[B](size)
+ copyToArray(result, 0)
+ result
+ }
+ else toStream.toArray
}
/** Converts this $coll to a list.