RFR: 8327156: Avoid copying in StringTable::intern(oop, TRAPS)

David Holmes dholmes at openjdk.org
Mon Oct 21 10:16:05 UTC 2024


On Fri, 18 Oct 2024 11:37:12 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> You're right, I meant the number of code points..
>> 
>> The `num_unicode_points` in this case would come from `UTF8::unicode_length`, which would give 2 from the 6-byte UTF8 string in your example. But I agree that it is somewhat unclear, especially if someone were to use this function in the future.
>> 
>> I have two ideas how this could be improved:
>> I could either add clarifying comments and change naming across the different functions to be clearer on how to use and call correctly. Or I could instead change it so that the function takes the UTF8-length instead of the UTF16-length. That way you always pass the array length to the function.
>
> I just want consistency and clarity in the header prototypes, for me either option is fine.

I agree with Johan, that either option would work, but as we are comparing different representations of strings so need a common format, and UTF-8 is the "lowest common denominator" then perhaps that is slightly better - and has the advantage of maintaining the correlation with the array length. The meaning of the parameters should always be clear.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21325#discussion_r1808484174


More information about the hotspot-dev mailing list