You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Sun (JIRA)" <ji...@apache.org> on 2019/04/06 13:19:00 UTC

[jira] [Created] (GROOVY-9072) Avoid creating inner classes for simple native lambda expressions

Daniel Sun created GROOVY-9072:
----------------------------------

             Summary: Avoid creating inner classes for simple native lambda expressions
                 Key: GROOVY-9072
                 URL: https://issues.apache.org/jira/browse/GROOVY-9072
             Project: Groovy
          Issue Type: Improvement
            Reporter: Daniel Sun
            Assignee: Daniel Sun


Groovy will create inner classes for each native lambda expression because native lambda expression is versatile and mimic the behavior of closure as possible as it can.

As a result, the performance of native lambda expression will be a bit less efficient than Java lambda expression.

We can generate almost same bytecode for the simple native lambda expressions, e.g. no re-assignment of shared variables in the lambda expression body, no nested lambda expression.

 The improvement can cover most of usual cases, e.g.
{code:java}
Stream.of(1, -2, 3).map(e -> Math.abs(e))
{code}




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)