On Sat, 1 Feb 2025 21:04:29 GMT, Johannes Graham <d...@openjdk.org> wrote:
>> Shaojin Wen has updated the pull request with a new target base due to a >> merge or a rebase. The pull request now contains 29 commits: >> >> - Merge remote-tracking branch 'upstream/master' into dec_to_str_202501 >> >> # Conflicts: >> # src/java.base/share/classes/jdk/internal/util/DecimalDigits.java >> - remove getChars(long, int, char[]) >> - copyright >> - Merge remote-tracking branch 'upstream/master' into dec_to_str_202501 >> >> # Conflicts: >> # src/java.base/share/classes/jdk/internal/util/DecimalDigits.java >> - simplify and comments >> - simplify >> - simplify >> - code style >> - revert change >> - bug fix >> - ... and 19 more: https://git.openjdk.org/jdk/compare/651ac3cc...f9af0b02 > > src/java.base/share/classes/java/math/BigDecimal.java line 4329: > >> 4327: >> 4328: private static String scale2(int intCompact) { >> 4329: int highInt = intCompact / 100; > > Something to experiment with here: > > int highInt = intCompact / 100; > int lowInt = intCompact - highInt * 100; > short packed=DecimalDigits.pair(lowInt); > > return new StringBuilder() > .append(highInt) > .append('.') > .append((char) (packed & 0xFF)) > .append((char) (packed >> 8)) > .toString(); > > > C2 seems to be able to optimize out the SB here, so it might do as well as > `newStringNoRepl`. Good suggestion, but DecimalDigits no longer provides a pair method ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/23310#discussion_r1938409275