Skip to content
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

Inefficient new Byte, Integer, Character constructor calls in ASM ClassReader [SPR-12365] #16970

Closed
spring-projects-issues opened this issue Oct 23, 2014 · 4 comments
Assignees
Labels
in: core type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Oct 23, 2014

vincent Kim opened SPR-12365 and commented

There are some inefficient new Byte, Character, Integer constructor in ClassReader class.

->
ex) av.visit(name, new Byte((byte) readInt(items[readUnsignedShort(v)])));

It would be better for performance to use static method, valueOf(),.

Such as Byte.valueOf(), Character.valueOf(), Integer.valueOf().

In valueOf method, cached values will be returned.

For giving better performance, use valueOf static method instead of new Constructor.


Affects: 4.1.1

Issue Links:

  • #16990 String comparison using .equals() in ASM ClassReader

Referenced from: commits b16048b

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 23, 2014

vincent Kim commented

I have submitted pull request
-> #674

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 23, 2014

Juergen Hoeller commented

It's worth noting that this is ASM code, not Spring code. However, since we effectively include our own fork of ASM there, we can apply optimizations.

As for the actual optimization, that's a good catch. However, it seems even more attractive to change that code to autoboxing (i.e. just pass in the primitive values) since the JVM will then internally use valueOf itself.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 27, 2014

vincent Kim commented

ValueOf method is replaced to autoboxing, as Juergen said.

I have submitted pull request
-> #680

Thanks.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 28, 2014

Juergen Hoeller commented

Thanks for updating the pull request - however, I've already applied a corresponding change to master a few days ago...

Let me know if there is anything else to change still.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants