[foreign-memaccess+abi] RFR: 8313238: Improve the performance of strlen for null-terminated strings [v3]
Per Minborg
pminborg at openjdk.org
Thu Aug 10 08:38:01 UTC 2023
On Wed, 9 Aug 2023 21:37:53 GMT, ExE Boss <duke at openjdk.org> wrote:
>> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Break out native invocations in separate methods
>
> src/java.base/share/classes/jdk/internal/foreign/StringSupport.java line 192:
>
>> 190: // iterate until overflow (String can only hold a byte[], whose length can be expressed as an int)
>> 191: for (int offset = 0; offset >= 0; offset += 2) {
>> 192: short curr = segment.get(JAVA_SHORT, offset);
>
> The old version intentionally used `JAVA_BYTE` here, as `strlen` and `strnlen` is for byte‑encoded strings (e.g.: **UTF‑8**):
> Suggestion:
>
> for (int offset = 0; offset >= 0; offset++) {
> short curr = segment.get(JAVA_BYTE, offset);
We are planning on a new PR that is using another algorithm.
-------------
PR Review Comment: https://git.openjdk.org/panama-foreign/pull/857#discussion_r1289760112
More information about the panama-dev
mailing list