RFR: 8269130: Replace usages of Collection.toArray() with Collection.toArray(T[]) to avoid redundant array copying
Andrey Turbanov
github.com+741251+turbanoff at openjdk.java.net
Mon Aug 9 07:19:35 UTC 2021
On Mon, 26 Jul 2021 19:55:09 GMT, Brett Okken <github.com+2996845+bokken 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/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/SystemDictionaryHelper.java line 92:
>
>> 90: }
>> 91:
>> 92: InstanceKlass[] searchResult = tmp.toArray(new InstanceKlass[0]);
>
> Is it too far outside the scope of these changes to make `tmp` an `ArrayList` rather than a `Vector`?
I'll create separate PRs to migrate Vector usages to ArrayList.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4487
More information about the serviceability-dev
mailing list