summaryrefslogtreecommitdiff
path: root/test/files/run/t2818.scala
diff options
context:
space:
mode:
authorJames Iry <jamesiry@gmail.com>2013-01-30 15:29:42 -0800
committerJames Iry <jamesiry@gmail.com>2013-01-31 14:16:59 -0800
commit6db4db93a7d976f1a3b99f8f1bffff23a1ae3924 (patch)
tree1a4ee752d56913426f76fbcee657480af57af0c5 /test/files/run/t2818.scala
parent7026376dcc87f531de84c99aa3e52068f5b10874 (diff)
downloadscala-6db4db93a7d976f1a3b99f8f1bffff23a1ae3924.tar.gz
scala-6db4db93a7d976f1a3b99f8f1bffff23a1ae3924.tar.bz2
scala-6db4db93a7d976f1a3b99f8f1bffff23a1ae3924.zip
SI-2818 Make List.foldRight always do a reverse/foldLeft flip
Benchmarks show that lists smaller than 110 elements or so doing reverse/foldLeft is faster than recursively walking to the end of the list and then folding as the stack unwinds. Above that 110 element threshold the recursive procedure is faster. Unfortunately, at some magic unknown large size the recursive procedure blows the stack. This commit changes List#foldRight to always do reverse/foldLeft.
Diffstat (limited to 'test/files/run/t2818.scala')
-rw-r--r--test/files/run/t2818.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/files/run/t2818.scala b/test/files/run/t2818.scala
new file mode 100644
index 0000000000..19b67cbc88
--- /dev/null
+++ b/test/files/run/t2818.scala
@@ -0,0 +1,6 @@
+object Test extends App {
+ println((List.range(1L, 15L) :\ 0L) (_ + _))
+ println((List.range(1L, 1000000L) :\ 0L) (_ + _))
+ println((List.fill(5)(1) :\ 1) (_ - _))
+ println((List.fill(1000000)(1) :\ 1) (_ - _))
+}