On Sun, 20 Oct 2024 00:19:25 GMT, Shaojin Wen <s...@openjdk.org> wrote:
> Move getChars methods of StringLatin1 and StringUTF16 to DecimalDigits to > reduce duplication > > 1. HexDigits and OctalDigits also include getCharsLatin1 and getCharsUTF16 > 2. Putting these two methods into DecimalDigits can avoid the need to expose > them in JavaLangAccess > 3. Eliminate duplicate code in BigDecimal src/java.base/share/classes/java/math/BigDecimal.java line 4216: > 4214: // Get the significand as an absolute value > 4215: if (intCompact != INFLATED) { > 4216: coeff = new char[19]; A possibility here would be to change `coeff` to be a String. The “else” branch already creates a string and has to additionally create a char array from it. If this is the only place where the `DecimalDigits.getChars(… char[])`, some extra code duplication could be removed. The `offset` could then also be removed ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21593#discussion_r1807902456