On Wed, 1 Mar 2023 10:05:27 GMT, Adam Sotona <asot...@openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/classfile/impl/ChainedFieldBuilder.java
>>  line 48:
>> 
>>> 46:         this.consumer = consumer;
>>> 47:         FieldBuilder b = downstream;
>>> 48:         while (b instanceof ChainedFieldBuilder cb)
>> 
>> I'm probably missing something - but if `b` is another chained builder, 
>> instead of using a loop, can't we just skip to its  `terminal` field? Also, 
>> the `downstream` field seems unused. (same considerations apply for 
>> `ChainedMethodBuilder` and `ChainedClassBuilder`).
>> 
>> I note that `NonTerminalCodeBuilder` seems to be already doing what I 
>> suggest here (e.g. skip to `terminal`).
>
> I would have to test possible side-effects of the proposed shortcut to give 
> you answer.
> Thanks for pointing it out.

Proposed shortcut seems to be OK, I've fixed it in `ChainedFieldBuilder`, 
`ChainedMethodBuilder` and `ChainedClassBuilder`. And removed unused 
`ChainedFieldBuilder.downstream` field.

-------------

PR: https://git.openjdk.org/jdk/pull/10982

Reply via email to