RFR: 8286663: Resolve IDE warnings in WTrayIconPeer and SystemTray
Sergey Bylokhov
serb at openjdk.java.net
Mon May 23 20:37:46 UTC 2022
On Mon, 23 May 2022 20:28:30 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> It's explained in Aleksey Shipilёv's article
>> https://shipilev.net/blog/2016/arrays-wisdom-ancients/
>>
>> In short, zero-sized array avoids the need for JVM to zero all array elements before they're overwritten with real values. On the other hand, this is likely negligible with very small arrays.
>
> 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.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8850
More information about the client-libs-dev
mailing list