DATACMNS-1673 - Use Method.getParameterCount() where possible to improve performance.
Original pull request: #426.
This commit is contained in:
committed by
Mark Paluch
parent
48e49babe3
commit
5f3102144c
@@ -65,15 +65,15 @@ public abstract class Parameters<S extends Parameters<S, T>, T extends Parameter
|
||||
|
||||
Assert.notNull(method, "Method must not be null!");
|
||||
|
||||
List<Class<?>> types = Arrays.asList(method.getParameterTypes());
|
||||
Class<?>[] types = method.getParameterTypes();
|
||||
|
||||
this.parameters = new ArrayList<>(types.size());
|
||||
this.parameters = new ArrayList<>(types.length);
|
||||
this.dynamicProjectionIndex = -1;
|
||||
|
||||
int pageableIndex = -1;
|
||||
int sortIndex = -1;
|
||||
|
||||
for (int i = 0; i < types.size(); i++) {
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
|
||||
MethodParameter methodParameter = new MethodParameter(method, i);
|
||||
methodParameter.initParameterNameDiscovery(discoverer);
|
||||
|
||||
@@ -300,12 +300,13 @@ class ReflectionRepositoryInvoker implements RepositoryInvoker {
|
||||
|
||||
Method method = methods.getFindAllMethod()
|
||||
.orElseThrow(() -> new IllegalStateException("Repository doesn't have a find-all-method declared!"));
|
||||
Class<?>[] types = method.getParameterTypes();
|
||||
|
||||
if (types.length == 0) {
|
||||
if (method.getParameterCount() == 0) {
|
||||
return invokeForNonNullResult(method);
|
||||
}
|
||||
|
||||
Class<?>[] types = method.getParameterTypes();
|
||||
|
||||
if (Pageable.class.isAssignableFrom(types[0])) {
|
||||
return invokeForNonNullResult(method, pageable);
|
||||
}
|
||||
|
||||
@@ -166,6 +166,7 @@ public class Function {
|
||||
public boolean isSignatureEqual(Function other) {
|
||||
|
||||
return getName().equals(other.getName()) //
|
||||
&& method.getParameterCount() == other.method.getParameterCount()
|
||||
&& Arrays.equals(method.getParameterTypes(), other.method.getParameterTypes());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user