-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
None
-
b15
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 allocates lightweight objects with 1 and two fields respectively 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.
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 allocates lightweight objects with 1 and two fields respectively 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.