DATACMNS-925 - Improve memory consumption of Parameter and Parameters.
This commit changes some ArrayList initializations to use an initial capacity and avoids the unnecessary fetch of the return type of a method in Parameter.isDynamicProjectionParameter(). Original pull request: #180.
This commit is contained in:
committed by
Oliver Gierke
parent
5bb60b6f0b
commit
62617bef05
@@ -194,13 +194,13 @@ public class Parameter {
|
||||
|
||||
ClassTypeInformation<?> ownerType = ClassTypeInformation.from(parameter.getDeclaringClass());
|
||||
TypeInformation<?> parameterTypes = ownerType.getParameterTypes(method).get(parameter.getParameterIndex());
|
||||
TypeInformation<Object> returnType = ClassTypeInformation.fromReturnTypeOf(method);
|
||||
|
||||
if (!parameterTypes.getType().equals(Class.class)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TypeInformation<?> bound = parameterTypes.getTypeArguments().get(0);
|
||||
TypeInformation<Object> returnType = ClassTypeInformation.fromReturnTypeOf(method);
|
||||
return bound.equals(returnType.getActualType());
|
||||
}
|
||||
|
||||
|
||||
@@ -62,11 +62,11 @@ public abstract class Parameters<S extends Parameters<S, T>, T extends Parameter
|
||||
|
||||
Assert.notNull(method);
|
||||
|
||||
this.parameters = new ArrayList<T>();
|
||||
this.dynamicProjectionIndex = -1;
|
||||
|
||||
List<Class<?>> types = Arrays.asList(method.getParameterTypes());
|
||||
|
||||
this.parameters = new ArrayList<T>(types.size());
|
||||
this.dynamicProjectionIndex = -1;
|
||||
|
||||
for (int i = 0; i < types.size(); i++) {
|
||||
|
||||
MethodParameter methodParameter = new MethodParameter(method, i);
|
||||
@@ -98,12 +98,12 @@ public abstract class Parameters<S extends Parameters<S, T>, T extends Parameter
|
||||
*/
|
||||
protected Parameters(List<T> originals) {
|
||||
|
||||
this.parameters = new ArrayList<T>();
|
||||
|
||||
int pageableIndexTemp = -1;
|
||||
int sortIndexTemp = -1;
|
||||
int dynamicProjectionTemp = -1;
|
||||
|
||||
this.parameters = new ArrayList<T>(originals.size());
|
||||
|
||||
for (int i = 0; i < originals.size(); i++) {
|
||||
|
||||
T original = originals.get(i);
|
||||
|
||||
Reference in New Issue
Block a user