[foreign-memaccess+abi] RFR: 8270376: Finalize API for memory copy [v4]
Uwe Schindler
uschindler at openjdk.java.net
Thu Jul 15 21:22:36 UTC 2021
On Tue, 13 Jul 2021 20:31:12 GMT, Uwe Schindler <uschindler at openjdk.org> wrote:
>> Maurizio Cimadamore has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Make `copyFrom` a default method
>> - Drop memory copy primitive using Object, but keep internal centralized implementation
>> Move MemorySegment copy methods as static methods in MemorySegment
>
> src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/SharedUtils.java line 293:
>
>> 291: int len = strlen(segment, start);
>> 292: byte[] bytes = new byte[len];
>> 293: MemoryCopy.copy(segment, start, MemorySegment.ofArray(bytes), 0, len);
>
> No need to wrap the byte array. Just use the other copy method taking byte[]. This spares another object allocation.
Thanks for the update!
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/568
More information about the panama-dev
mailing list