eclipse-archived / ceylon

The Ceylon compiler, language module, and command line tools
http://ceylon-lang.org
Apache License 2.0
396 stars 62 forks source link

Optimisation: Named argument with getters #786

Open CeylonMigrationBot opened 11 years ago

CeylonMigrationBot commented 11 years ago

[@FroMage] This code:

    Boolean m() {
        return f {
            String s { return "foo"; }
            Integer n { return 2; }
        };
    }

Compiles currently to:

    private final boolean m() {
        return (
            let
            {

                final class $s$1 {

                    private $s$1() {
                    }

                    .java.lang.String getS() {
                        return "foo";
                    }
                }
                final $s$1 $s$1 = new $s$1();
                final .java.lang.String $arg$0$1 = $s$1.getS();

                final class $n$2 {

                    private $n$2() {
                    }

                    long getN() {
                        return 2L;
                    }
                }
                final $n$2 $n$2 = new $n$2();
                final long $arg$0$0 = $n$2.getN();
            }
            returning f($arg$0$0, $arg$0$1);
        );
    }

I think we can make it faster like that:

    private final boolean m() {
        return (
            let
            {

                final .java.lang.String $arg$0$1 = let { } returning "foo";
                final long $arg$0$0 = let { } returning 2L;
            }
            returning f($arg$0$0, $arg$0$1);
        );
    }

[Migrated from ceylon/ceylon-compiler#786]

CeylonMigrationBot commented 11 years ago

[@FroMage] Moving to M6

CeylonMigrationBot commented 11 years ago

[@FroMage] Moved to 1.0

CeylonMigrationBot commented 10 years ago

[@FroMage] Moving to 1.2