Current (Integer|Long).getChars are using the non-idiomatic constructs, possibly targeted to improve performance, see e.g.:
for (;;) {
q2 = (i2 * 52429) >>> (16+3); // q2 = q2 / 10
r = i2 - ((q2 << 3) + (q2 << 1)); // r = i2-(q2*10) ...
buf[--charPos] = Integer.digits[r];
i2 = q2;
if (i2 == 0) break;
}
This was apparently done before 1994 (estimate given by Josh Bloch), way before Java optimizing compilers could do strength-reduction on their own, and on some hardware manually replacing multiplications and divisions helped. It does not appear true anymore. Therefore, we need to see if we want a more idiomatic code there.
Sample benchmark:
http://cr.openjdk.java.net/~shade/8136500/LongToString.java
Sample result shows improvement with a very dumb patch:
http://cr.openjdk.java.net/~shade/8136500/notes.txt
Other things to do:
a) Make sure strength-reductions happen at least in C2-optimized code;
b) Do the same for Integer.