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

Conversation

dreis2211
Copy link
Contributor

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

@odrotbohm odrotbohm left a comment

Choose a reason for hiding this comment

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

A couple of minor comments. LGTM beyond that. Thanks for taking the time!

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().

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.

odrotbohm pushed a commit that referenced this pull request Oct 16, 2016
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.
odrotbohm added a commit that referenced this pull request Oct 16, 2016
Moved an assignment back to its original place to create instance state as early as possible.

Original pull request: #180.
odrotbohm pushed a commit that referenced this pull request Oct 16, 2016
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.
odrotbohm added a commit that referenced this pull request Oct 16, 2016
Moved an assignment back to its original place to create instance state as early as possible.

Original pull request: #180.
@odrotbohm
Copy link
Member

That's merged, thanks!

@odrotbohm odrotbohm closed this Oct 16, 2016
@odrotbohm odrotbohm self-assigned this Oct 16, 2016
Aloren pushed a commit to Aloren/spring-data-commons that referenced this pull request Jun 20, 2019
Making SimpleDiscoveryClient the default, marking NoOpDiscoveryClient as deprecated

fixes spring-projectsgh-180
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants