In, AutowireUtils.sortConstructors(), Using valueOf is faster than using constructor [SPR-12385] #16993
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
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;
Affects: 4.1.1
Reference URL: #682
Referenced from: commits 4945cf1
The text was updated successfully, but these errors were encountered: