Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-12385

In, AutowireUtils.sortConstructors(), Using valueOf is faster than using constructor

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 4.1.1
    • Fix Version/s: 4.1.2
    • Component/s: Core

      Description

      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;

        Attachments

          Activity

            People

            Assignee:
            juergen.hoeller Juergen Hoeller
            Reporter:
            overmindx Kang Baek-Kyu
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              3 years, 30 weeks, 1 day ago