Skip to content

DATACMNS-925 - Improve memory consumption of Parameter and Parameters. #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ private static boolean isDynamicProjectionParameter(MethodParameter 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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public Parameters(Method method) {

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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind keeping the old position of the code and only add the initial sizing? Moving the code doesn't seem to have any effect here and types was declared as close to its usage (the loop below) by purpose. Or do I oversee anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need the types variable here in order to retrieve the size. If I call method.getParameters() again I have the overhead of cloning the method parameters, which I wanted to avoid. As far as I saw, you're not yet compiling against Java 8, which would have enabled me to call Method.getParameterCount().

this.dynamicProjectionIndex = -1;

for (int i = 0; i < types.size(); i++) {

MethodParameter methodParameter = new MethodParameter(method, i);
Expand Down Expand Up @@ -98,12 +98,12 @@ public Parameters(Method method) {
*/
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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above. Defining an initial size for the array seems like a good idea. However, that doesn't need the code moved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case your right, this was just for "consistency" to the method above. Let me know when I should change it.


for (int i = 0; i < originals.size(); i++) {

T original = originals.get(i);
Expand Down