<i18n dev> RFR: 8275106: Cleanup Iterator usages in java.desktop

Andrey Turbanov duke at openjdk.java.net
Tue Oct 12 08:08:02 UTC 2021


On Tue, 12 Oct 2021 05:49:17 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> Cycles with 'Iterator' are error-prone. It's better to use more high-level code, which easier to read.
>> We can use enhanced-for or Collection.removeIf
>
> src/java.desktop/unix/classes/sun/awt/X11/ListHelper.java line 569:
> 
>> 567: 
>> 568:     private boolean isItemSelected(int index) {
>> 569:         for (Integer val : selected) {
> 
> In some other places you did unboxing for the loop var, why not in this place?

I tried to mimic original code.
If in original code iterator.next() was assigned to a primitive - I use primitive for loop variable declaration.

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

PR: https://git.openjdk.java.net/jdk/pull/5871


More information about the i18n-dev mailing list