On Mon, 13 Sep 2021 11:06:15 GMT, Сергей Цыпанов
<[email protected]> wrote:
> 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.
The null-hostile-ness of `contains` is not something I thought about. It would
have been good to mention that in the PR body as well. FWIW, I did a search on
grep.app for `parameterList()` calls in java [1] and don't really see any calls
to `contains`.
I think process-wise creating a CSR would be good, and shouldn't be too much
work. Though, I'm not familiar with the process of filing a CSR after a patch
has already been merged.
[1] : https://grep.app/search?q=.parameterList%28%29&filter[lang][0]=Java
-------------
PR: https://git.openjdk.java.net/jdk/pull/5489