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

Use table lookup for the last two bytes in Integer.getChars

XMLWordPrintable

    • b06

      During TemplatedStrings work Jim noticed that we could probably profit from reuse the same table lookup mechanism we're using for the rightmost bytes also for the 1 or 2 leftmeost bytes:

              // We know there are at most two digits left at this point.
              buf[--charPos] = DigitOnes[-i];
              if (i < -9) {
                  buf[--charPos] = DigitTens[-i];
              }

      This avoids some arithmetic, and the tables are likely to be cached. A small improvements on microbenchmarks, including Integers.toString, can be observed.

            redestad Claes Redestad
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: