RFR: 8286663: Resolve IDE warnings in WTrayIconPeer and SystemTray [v3]

Sergey Bylokhov serb at openjdk.java.net
Thu Jun 2 21:51:33 UTC 2022


On Thu, 2 Jun 2022 08:18:21 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> BTW I think that the usage of 
>> `return icons.toArray(EMPTY_TRAY_ARRAY);`
>> is slower than any of other cases: presized or zero. So if we would like to use a similar pattern the zero version is better.
>
>> BTW I think that the usage of
>> `return icons.toArray(EMPTY_TRAY_ARRAY);`
>> is slower than any of other cases: presized or zero. So if we would like to use a similar pattern the zero version is better.
> 
> Why is it? It's the same as `icons.toArray(new TrayIcon[0])` without creating a new zero-sized array.

It should be checked of course, but in zero case the size is known by the compiler not sure that in the cached case it can make the same optimizations. The article above said the cached case is a "marginal improvement over new Foo[0]"

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

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



More information about the client-libs-dev mailing list