Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#2013 CIMObjectPath uses # constructor instead of valueOf

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

CIMObjectPath's internal TypeValuePair constructor calls the Byte/Short/Integer/Long constructor instead of using the better performing valueOf() method.

Bug: Method new javax.cim.CIMObjectPath$TypeValuePair(IntegerValue) invokes inefficient new Byte(byte) constructor; use Byte.valueOf(byte) instead
Bug: Method new javax.cim.CIMObjectPath$TypeValuePair(IntegerValue) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
Bug: Method new javax.cim.CIMObjectPath$TypeValuePair(IntegerValue) invokes inefficient new Long(long) constructor; use Long.valueOf(long) instead
Bug: Method new javax.cim.CIMObjectPath$TypeValuePair(IntegerValue) invokes inefficient new Short(short) constructor; use Short.valueOf(short) 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 4 FindBugs issues

     
  • Dave Blaschke
    Dave Blaschke
    2010-06-30

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

    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-01

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

    Patch against HEAD

     
    Attachments
  • Dave Blaschke
    Dave Blaschke
    2010-07-28

    • status: open-fixed --> pending-fixed
     
  • 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-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