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?
to your account
Kang Baek-Kyu opened SPR-12385 and commented
Using valueOf is approximately 3.5 times faster than using constructor
Because Using new Integer(int) is guaranteed to always result in a new object whereas Integer.valueOf(int) allows caching of values to be done by the compiler, class library, or JVM.
So changed source like this
return (new Integer(c1pl)).compareTo(c2pl) * -1;
==>return (Integer.valueOf(c1pl)).compareTo(c2pl) * -1;
Reference URL: #682
Referenced from: commits 4945cf1
The text was updated successfully, but these errors were encountered:
Juergen Hoeller commented
Good catch! However, there's an even more efficient way of expressing this:
return (c1pl < c2pl ? 1 : (c1pl > c2pl ? -1 : 0));
analogous to the Integer.compare(int, int) method in Java 7. I've applied this change to both constructor and factory method sorting for 4.1.2 now.
Sorry, something went wrong.
I've also applied analogous changes to ReflectiveConstructorResolver and ReflectiveMethodResolver in SpEL.
Kang Baek-Kyu commented
Aha. Hou did not know that there is a new way.
No branches or pull requests