On Sat, 23 Sep 2023 07:39:59 GMT, 温绍锦 <[email protected]> wrote:
>> 1. Reduce duplicate stringSize code
>> 2. Move java.lang.StringLatin1.getChars to
>> jdk.internal.util.DecimalDigits::getCharLatin1,not only java.lang, other
>> packages also need to use this method
>
> 温绍锦 has updated the pull request incrementally with one additional commit
> since the last revision:
>
> refactor HexDigits & OctalDigits & FormatItem, FormatItem#prepend provides
> two implementations: prependLatin1 and prependUTF16
Since the current `MethodHandle`-based char putter can only put 1-byte at once,
have you considered something like this:
// A replacement for setter MethodHandle, or VarHandle, to accept multiple
value types
public interface DigitConsumer {
void putChar(byte[] array, int index, byte value);
// put 2 byte-sized chars at once, encoded little endian
void putChar2(byte[] array, int index, short value);
// you can add putChar4, putChar8, etc. if you need
}
and `StringConcatHelper.selectPutChar` will return a `DigitConsumer` instead of
a `MethodHandle`.
Currently, you are allocating a new byte array for every number in the format,
which I deem very inefficient.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15699#issuecomment-1732267099