summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/IterableLike.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-08-13 13:04:18 -0700
committerPaul Phillips <paulp@improving.org>2012-08-13 13:08:42 -0700
commitcaf7eb6b56817fd1e1fbc1cf017f30e6f94c6bea (patch)
treebabb9a8b3e7c76f243d1649d72c0553476562cb2 /src/library/scala/collection/IterableLike.scala
parent8cfba0fb219a49cceeb0318a6562aa3a602d913c (diff)
downloadscala-caf7eb6b56817fd1e1fbc1cf017f30e6f94c6bea.tar.gz
scala-caf7eb6b56817fd1e1fbc1cf017f30e6f94c6bea.tar.bz2
scala-caf7eb6b56817fd1e1fbc1cf017f30e6f94c6bea.zip
Fix for view isEmpty.
Views have been inheriting the very inefficient isEmpty from Traversable, and since isEmpty is not specifically forwarded to the underlying collections, views miss out on all the important optimizations in those collections which tend to be implemented via method override. Not to mention, they miss out on correctness, because calling foreach has a habit of forcing the first element of the view.
Diffstat (limited to 'src/library/scala/collection/IterableLike.scala')
-rw-r--r--src/library/scala/collection/IterableLike.scala3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/library/scala/collection/IterableLike.scala b/src/library/scala/collection/IterableLike.scala
index 2e9599058f..ac6d754f9e 100644
--- a/src/library/scala/collection/IterableLike.scala
+++ b/src/library/scala/collection/IterableLike.scala
@@ -171,7 +171,7 @@ self =>
* fewer elements than size.
*/
def sliding(size: Int): Iterator[Repr] = sliding(size, 1)
-
+
/** Groups elements in fixed size blocks by passing a "sliding window"
* over them (as opposed to partitioning them, as is done in grouped.)
* @see [[scala.collection.Iterator]], method `sliding`
@@ -293,6 +293,7 @@ self =>
override /*TraversableLike*/ def view = new IterableView[A, Repr] {
protected lazy val underlying = self.repr
+ override def isEmpty = self.isEmpty
override def iterator = self.iterator
}