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

[REDO] Move getChars to DecimalDigits

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 25
    • None
    • core-libs
    • None
    • b08

      This issue is a redo issue after 8342650 was rolled back.

      Move getChars methods of StringLatin1 and StringUTF16 to DecimalDigits to reduce duplication

      HexDigits and OctalDigits also include getCharsLatin1 and getCharsUTF16

      Putting these two methods into DecimalDigits can avoid the need to expose them in JavaLangAccess
      Eliminate duplicate code in BigDecimal

      This PR will improve the performance of Integer/Long.toString and StringBuilder.append(int/long) scenarios. This is because Unsafe.putByte is used to eliminate array bounds checks, and of course this elimination is safe.

      In previous versions, in Integer/Long.toString and StringBuilder.append(int/long) scenarios, -COMPACT_STRING performed better than +COMPACT_STRING. This is because StringUTF16.getChars uses StringUTF16.putChar, which is similar to Unsafe.putChar, and there is no bounds check.

            swen Shaojin Wen
            swen Shaojin Wen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: