On Fri, 18 Apr 2025 02:45:56 GMT, Chen Liang <li...@openjdk.org> wrote:

>> We need to provide a StringBuilder that creates a coder of UTF16 to avoid 
>> the unnecessary UTF16 to LATIN1 conversion overhead here. 
>> 
>> If we do not want to add a new public method, we can add an internal method 
>> and expose it through JLA for use here.
>
> `Reader` by specification works on `char`, so I think this is fine. Even if a 
> StringBuilder is UTF16, it still has to check for all-Latin1 characters at 
> the time of string creation, so not really an overhead elimination.

Seems you want to make the `result` StringBuilder fully expanded (maybeLatin1 = 
true, coder = UTF16) initially, so we just compress the whole builder with a 
vectorized intrinsic instead of char-by-char loop in `append`. Makes sense.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24728#discussion_r2049932051

Reply via email to