Additional mismatch overloads for memory segments

Alexander Biryukov sanya.rnd at gmail.com
Mon Jun 13 23:42:23 UTC 2022


 There is a method MemorySegment#mismatch, but it's kind of inefficient in
the following situation:

val seg1 = mem.asSlice(offset, size)
val seg2 = other.mem.asSlice(other.offset, other.size)
return seg1.mismatch(seg2) == -1L

There are additional mismatch methods in java.util.Arrays for arrays, like

public static int mismatch(byte[] a, int aFromIndex, int aToIndex,
                           byte[] b, int bFromIndex, int bToIndex)

It would be nice to have something like that for MemorySegment as well.
Or even better -- MemorySegment#compare :)

NB: is this the correct way to provide feedback?

Best regards,
Alexander Biryukov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20220614/14e4a9c0/attachment-0001.htm>


More information about the panama-dev mailing list