Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#2017 Listener uses # constructor instead of valueOf

Performance
closed-fixed
Dave Blaschke
5
2010-09-15
2010-06-30
Dave Blaschke
No

WBEMListenerSBLIM methods call the Integer constructor instead of using the better performing valueOf() method.

Bug: Method org.sblim.cimclient.WBEMListenerSBLIM.addListener(IndicationListener, int, String, String, Properties) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
Bug: Method org.sblim.cimclient.WBEMListenerSBLIM.removeListener(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
Pattern id: DM_NUMBER_CTOR, type: Bx, category: PERFORMANCE

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. Using of cached values avoids object allocation and the code will be faster.

Discussion

  • Dave Blaschke
    Dave Blaschke
    2010-06-30

    Fixing this eliminates 2 FindBugs issues

     
  • Dave Blaschke
    Dave Blaschke
    2010-06-30

    • status: open --> open-accepted
     
  • Dave Blaschke
    Dave Blaschke
    2010-07-02

    • status: open-accepted --> open-fixed
     
  • Dave Blaschke
    Dave Blaschke
    2010-07-02

    Patch sent for community review. During a 2 week period any
    exploiter may comment on the patch, request changes or turn it
    down completely (with good reason). For the time being the patch is part of the "Experimental" branch in CVS.

     
  • Dave Blaschke
    Dave Blaschke
    2010-07-28

    Patch against HEAD

     
    Attachments
  • Dave Blaschke
    Dave Blaschke
    2010-07-28

    The community review has completed and we received no substantial critisism. Therefore the patch has been approved and merged into the "HEAD" branch. The next release will pick it up.

     
  • Dave Blaschke
    Dave Blaschke
    2010-07-28

    • status: open-fixed --> pending-fixed
     
  • Dave Blaschke
    Dave Blaschke
    2010-09-15

    The patch was picked up by release 2.1.6 and will therefore be closed.

     
  • Dave Blaschke
    Dave Blaschke
    2010-09-15

    • status: pending-fixed --> closed-fixed