deduplicating lambda methods
Brian Goetz
brian.goetz at oracle.com
Wed Mar 21 19:19:38 UTC 2018
I think incremental optimizations like this (which add complexity, and
worse, beget more incremental optimizations) should be justified by data
that shows that these cases are common enough to warrant such a thing.
On 3/21/2018 3:00 PM, B. Blaser wrote:
> I note also that we may want to skip empty blocs '{}' and statements ';'.
> The following examples would then produce only 2 lambda methods
> instead of currently 8:
>
> Runnable r = () -> {};
> r = () -> { ; };
> r = () -> { {} };
> r = () -> { { ; } };
>
> r = () -> { int i = 0; if (i==0) ; };
> r = () -> { int i = 0; if (i==0) {} };
> r = () -> { int i = 0; if (i==0) { ; } };
> r = () -> { int i = 0; if (i==0) { {} } };
>
> I had to write a 'NoOpFinder' class (does something like that already
> exist?) and I added a default action in 'TreeScanner' for that (see
> below).
>
> Does this look reasonable (I did only some quick tests)?
More information about the amber-dev
mailing list