Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6274390

BigDecimal.doubleValue() performance improvement

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 5.0
    • core-libs
    • b45
    • x86
    • windows_xp

        A DESCRIPTION OF THE REQUEST :
        BigDecimal.doubleValue(), BigDecimal.floatValue(), BigInteger.doubleValue(), and BigInteger.floatValue() all create unneeded objects to return their results. For example, BigDecimal.doubleValue() could be changed from:
        return Double.valueOf(this.toString()).doubleValue();
        to
        return Double.parseDouble(this.toString());

        This avoids creating new Double objects just to call their doubleValue() methods
        to get the primitive value.

        The implemenation of Double.parseDouble() and Double.valueOf() are nearly identical because they both ultimately call FloatingDecimal.readJavaFormatString(). So, this change should not change the methods' behavior.

        JUSTIFICATION :
        This change is an easy way to get improved performance out of these methods by not creating and destroying unneeded objects.
        ###@###.### 2005-05-23 11:08:59 GMT

              darcy Joe Darcy
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: