New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scanLeft (and right) for TraversableViewLike is very ineffective #9902
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9902?orig=1 |
@SethTisue said: |
@SethTisue said: |
@szeiger said: |
closing since everything is changing in the 2.13 collections. someone with an interest in this ticket could verify whether it still exists in scala/collection-strawman now, or wait for Scala 2.13.0-M4 to land (when collection-strawman will be merged) and check it then. |
This is fixed in strawman.
|
Now implementation of scanLeft for TraversableViewLike is this
It goes to calculate all the collection when we call some method of the "view". But it is not the way, because we may want to take only a part of collection with "takeWhile" or "find" or "indexWhere". It should be implemented like "foldLeft" for "views"—using "foreach" call. But better potential implementations of many view's methods are with "iterator". And it should not be forced—it is a "view" after all. All the operations should be lazy.
Now it is 100 times slower than it should be.
Probably, they are another view methods, these have non-lazy implementations.
The text was updated successfully, but these errors were encountered: