Currently the method is implemented like public List<Class<?>> parameterList() { return Collections.unmodifiableList(Arrays.asList(ptypes.clone())); }
This seems to be excessive, as three objects are allocated here. Instead we can use `List.of(ptypes)` which doesn't allocate anything for empty array and for one of length 1 and 2 it allocates lightweight objects with 2 fields, still copying longer arrays. This is likely to be fruitful as most of methods have 0-2 parameters. Also there is a couple of cases when `MethodType.parameterLis()` is called to get its size, which is excessive either as we can use `MethodType.parameterCount()` instead. ------------- Commit messages: - 8273656: Improve java.lang.invoke.MethodType.parameterList() and its usage Changes: https://git.openjdk.java.net/jdk/pull/5489/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5489&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8273656 Stats: 7 lines in 2 files changed: 0 ins; 0 del; 7 mod Patch: https://git.openjdk.java.net/jdk/pull/5489.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/5489/head:pull/5489 PR: https://git.openjdk.java.net/jdk/pull/5489