<AWT Dev> RFR: 8269130: Replace usages of Collection.toArray() with Collection.toArray(T[]) to avoid redundant array copying

Sergey Bylokhov serb at openjdk.java.net
Mon Jul 26 11:30:23 UTC 2021


On Mon, 14 Jun 2021 17:00:29 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:

> I found few places, where code initially perform `Object[] Colleciton.toArray()` call and then manually copy array into another array with required type.
> This PR cleanups such places to more shorter call `T[] Collection.toArray(T[])`.

src/java.desktop/share/classes/sun/java2d/SunGraphicsEnvironment.java line 191:

> 189:                         installed[i]);
> 190:             }
> 191:             String[] retval = map.keySet().toArray(new String[0]);

Looks like previously the code returns values, and now it will return keys, please recheck.

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

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


More information about the awt-dev mailing list