diff options
author | Paul Phillips <paulp@improving.org> | 2013-03-26 23:50:50 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-03-26 23:51:25 -0700 |
commit | e3ddb2d7dff859c9fb81d34d1c9687f72321a713 (patch) | |
tree | 1d520b035e5306214fe39ef5333ab7b55caa7867 /CONTRIBUTING.md | |
parent | 59d4998cf4a19eb5d44118d4867c2370e9a935e5 (diff) | |
download | scala-e3ddb2d7dff859c9fb81d34d1c9687f72321a713.tar.gz scala-e3ddb2d7dff859c9fb81d34d1c9687f72321a713.tar.bz2 scala-e3ddb2d7dff859c9fb81d34d1c9687f72321a713.zip |
Iterator.++ no longer blows the stack.
To my chagrin we still hadn't gotten this one. I took a new
approach which seems like a winner to me. Here's a benchmark:
object Test {
def run(n: Int) = println((1 to n).foldLeft(Iterator.empty: Iterator[Int])((res, _) => res ++ Iterator(1)) sum)
def main(args: Array[String]): Unit = run(args(0).toInt)
}
Runtime before this commit for various n:
500 0.403 real
1000 0.911 real
1500 2.351 real
2000 5.298 real
2500 10.184 real
Runtime after this commit, same n:
500 0.346 real
1000 0.359 real
1500 0.368 real
2000 0.379 real
2500 0.390 real
In the test case I dial it up to 100000.
Diffstat (limited to 'CONTRIBUTING.md')
0 files changed, 0 insertions, 0 deletions