RFR: 8286663: Resolve IDE warnings in WTrayIconPeer and SystemTray

Phil Race prr at openjdk.java.net
Mon May 23 21:14:58 UTC 2022


On Mon, 23 May 2022 20:34:27 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> In fact, there's no need to create zero-sized array, there's one already: `EMPTY_TRAY_ARRAY`.
>> 
>> Yet the code may look weird with it.
>> 
>> 
>> return icons.toArray(EMPTY_TRAY_ARRAY);
>
> We probably can extract this to the separate cleanup, the resulted code is smaller and faster.
> PS I have added a link to my previous message accidentally hit submit button.

I'm sure I've used this pattern
return icons.toArray(EMPTY_TRAY_ARRAY);
in code that runs often and may be performance sensitive, so I don't see anything weird about it.
OTOH I am not sure this code is anything that needs super-optimising .. we seem to have gone down that discussion route because it was the justification for the change.

BTW the shiplev article, which I skimmed must be suggesting that the array initialisation must be faster if it is on the array it allocates itself because of the APIs used .. but as he also notes things can change.

Anyway this is mildly interesting discussion but no one will ever, ever be able to measure a difference when it used here since it is probably 0.0001 % of the work ...

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

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



More information about the client-libs-dev mailing list