-
Notifications
You must be signed in to change notification settings - Fork 683
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()); | ||
this.dynamicProjectionIndex = -1; | ||
|
||
for (int i = 0; i < types.size(); i++) { | ||
|
||
MethodParameter methodParameter = new MethodParameter(method, i); | ||
|
@@ -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()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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().