RFR: 8294943: Implement record patterns in enhanced for [v6]
Jan Lahoda
jlahoda at openjdk.org
Mon Nov 7 12:43:40 UTC 2022
On Mon, 24 Oct 2022 19:03:22 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Address review
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java line 736:
>
>> 734: * <pre>{@code
>> 735: * for (<type-of-coll-item> N$temp : coll) {
>> 736: * switch (N$temp) {
>
> This is obviously a correct translation (I like that it delegates to what we already know how to do). I wonder if it would be better to use a pattern with `if/instanceof` (as the switch machinery is a tad expensive, and has an invokedynamic, which in this case could be avoided, I think?).
I was thinking of that, but (to me) it seemed better to handle that on the switch level, to avoid the indy for all switches with a single/few arms.
-------------
PR: https://git.openjdk.org/jdk/pull/10798
More information about the compiler-dev
mailing list