On Wed, 15 Dec 2021 23:04:37 GMT, Claes Redestad <redes...@openjdk.org> wrote:
> During TemplatedStrings work Jim has noticed that we could probably profit > from reusing the lookup tables also for the 1 or 2 leftmost 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 on average achieves a small speed-up since > the lookup tables are likely cached are likely to be in cache. Small > improvements on a few affected microbenchmarks, including the new > Integers.toStringTiny, can be observed. > > Baseline: > > Benchmark (size) Mode Cnt Score Error Units > Integers.toStringTiny 500 avgt 50 21.862 ± 0.211 us/op > > > Patch: > > Benchmark (size) Mode Cnt Score Error Units > Integers.toStringTiny 500 avgt 50 20.619 ± 0.330 us/op This pull request has now been integrated. Changeset: 71ca85f5 Author: Claes Redestad <redes...@openjdk.org> URL: https://git.openjdk.java.net/jdk/commit/71ca85f5a6741a2db55a529192564f94b269fbd9 Stats: 42 lines in 4 files changed: 11 ins; 16 del; 15 mod 8278831: Use table lookup for the last two bytes in Integer.getChars Reviewed-by: jlaskey, rriggs ------------- PR: https://git.openjdk.java.net/jdk/pull/6854