summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/generic
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-10-31 11:52:14 +0100
committerJason Zaugg <jzaugg@gmail.com>2013-10-31 11:52:14 +0100
commit7d09097aac4a3f0e802fdbc539014ec6018efd79 (patch)
treefa2327f74226d7a59811203c1b6064321a26a637 /src/library/scala/collection/generic
parentc38235fd44f1ccb280e31a2f34f58deb59c5b2ee (diff)
downloadscala-7d09097aac4a3f0e802fdbc539014ec6018efd79.tar.gz
scala-7d09097aac4a3f0e802fdbc539014ec6018efd79.tar.bz2
scala-7d09097aac4a3f0e802fdbc539014ec6018efd79.zip
Collections: remove redundant calls to .seq
Students of Scala's history might recall that at introduction of parallel collections, GenIterable et al were *not* added; instead the parallel collections inherited from the existing interfaces. This of course was an invitation to widespread disaster as any existing code that foreach-ed over a collection might now experience unwanted concurrency. The first attempt to fix this was to add the `.seq` method to convert a parallel colleciton to a sequential one. This was added in e579152f732, and call sites in the standard library with side-effecting foreach calls were changed to use that. But this was (rightly) deemed inadequate, as we could hardly expect people to change existing code or remember to do this in new code. So later, in 3de96153e5b, GenIterable was sprouted, and parallel collections were re-parented. This commit removes residual needless calls to .seq when the static type of the receiver is already a plain Iterable, which are no-ops.
Diffstat (limited to 'src/library/scala/collection/generic')
-rw-r--r--src/library/scala/collection/generic/Growable.scala2
-rw-r--r--src/library/scala/collection/generic/Shrinkable.scala2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/library/scala/collection/generic/Growable.scala b/src/library/scala/collection/generic/Growable.scala
index 254d4566be..a223c0c8a8 100644
--- a/src/library/scala/collection/generic/Growable.scala
+++ b/src/library/scala/collection/generic/Growable.scala
@@ -54,7 +54,7 @@ trait Growable[-A] extends Clearable {
loop(xs.tail)
}
}
- xs.seq match {
+ xs match {
case xs: scala.collection.LinearSeq[_] => loop(xs)
case xs => xs foreach +=
}
diff --git a/src/library/scala/collection/generic/Shrinkable.scala b/src/library/scala/collection/generic/Shrinkable.scala
index b5ec568667..dea5bb7217 100644
--- a/src/library/scala/collection/generic/Shrinkable.scala
+++ b/src/library/scala/collection/generic/Shrinkable.scala
@@ -46,5 +46,5 @@ trait Shrinkable[-A] {
* @param xs the iterator producing the elements to remove.
* @return the $coll itself
*/
- def --=(xs: TraversableOnce[A]): this.type = { xs.seq foreach -= ; this }
+ def --=(xs: TraversableOnce[A]): this.type = { xs foreach -= ; this }
}