rorygraves / scalac_perf

The Scala programming language
http://www.scala-lang.org/
16 stars 3 forks source link

Creating intermediate collections just to call `foreach` on them in the end (from bcode) #56

Open romanowski opened 6 years ago

romanowski commented 6 years ago

Example that represent the problem:

fieldSymbols function from here is producing List that is consumed here by only calling for each.

This particular example most likely will not produce significant improvements but I think it represent class of problems that can be fixed by strategic solution (like inlining or other optimization used during compilation of compiler code).

mkeskells commented 6 years ago

because of https://github.com/rorygraves/scalac_perf/issues/58 it probably creating 2 lists per cycle

mkeskells commented 6 years ago

probably can get some info from the collections instrumentation - a :: accessed once only