On Thu, 14 Sep 2023 13:44:59 GMT, Roger Riggs <[email protected]> wrote:
>> src/java.base/share/classes/jdk/internal/foreign/Utils.java line 277:
>>
>>> 275: }
>>> 276:
>>> 277: public static String toHexString(long value) {
>>
>> We intend to use this utility method in coming PRs.
>
> The String concat code is really good at optimizing, but this will require a
> new string be created.
> $0.02,Roger
Why not `HexFormat.of().withPrefix("0x").formatHexString(long)` I thought, then
realized there's no such method, only `toHexDigits` which ignores the
`HexFormat.prefix`. Having a format method that adds the prefix (and any suffix
+ delimiters) means creating this string could be done in a single step without
concatenation, and we'd consolidate all manners of usage to a single place.
Seems there might be room for improvement here.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15740#discussion_r1326032912