RFR: 8287442: Reduce list to array conversions in java.lang.invoke.MethodHandles
Rob Spoor
duke at openjdk.java.net
Fri May 27 15:35:44 UTC 2022
On Fri, 27 May 2022 14:18:19 GMT, Claes Redestad <redestad at openjdk.org> wrote:
> In preparation of #8855 this PR refactors the conversions from `List` to array and array to `List`, reducing the number of conversions when calling `MethodHandles.dropArguments` in particular. This remove about ~5% of allocations on the `StringConcatFactoryBootstraps` microbenchmark.
src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 5266:
> 5264: */
> 5265: public static MethodHandle dropArguments(MethodHandle target, int pos, List<Class<?>> valueTypes) {
> 5266: return dropArguments(target, pos, valueTypes.toArray(new Class<?>[0]).clone(), true);
Isn't this call to `clone()` unnecessary, as `valueTypes.toArray` should either return the passed empty array, or a newly created array?
-------------
PR: https://git.openjdk.java.net/jdk/pull/8923
More information about the core-libs-dev
mailing list