Skip to content

optimizing collection creation #6247

Open
@scabug

Description

@scabug

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"

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions