Open
Description
Quoting from https://groups.google.com/d/topic/scala-internals/5oRYBYBUqMY/discussion
When you create a collection, a lot of unnecessary work is done.
Quoting from https://groups.google.com/d/msg/scala-internals/5oRYBYBUqMY/aq93-oBpaukJ
I think there's a middle ground between what we have now and macro/builtin compiler support. This reminds me an idea I had (and Miguel also mentioned to me) of early inlining. The current state of affairs is that code with foreach call like List(1,2,3) foreach println we first expand lambda to a class, we typecheck everything and generate lots of trees, then icode and only then we realize (if we are lucky) that we can inline foreach implementation, inline apply of a closure and throw away the whole class we generate for the closure. That's a huge amount of wasted work.
Quoting from The Scala Compiler Corner, about "early inlining"
- 2012-07-03: GC-savvy Closure conversion,
http://lamp.epfl.ch/~magarcia/ScalaCompilerCornerReloaded/2012Q3/2012-07-01-GC-savvy-Closure-conversion.pdf - 2011-11-22: Just trying to generate faster code faster under -optimise
http://lamp.epfl.ch/~magarcia/ScalaNET/slides/2011-11-22-BetterInlining.pdf
Many of these performance problems can go away with MethodHandles and invokedynamic. Therefore this bug should be broken up into pre-JDK7 and JDK7 versions.