[foreign-memaccess+abi] RFR: 8274157: java.foreign: Add method MemorySegment::isOverlapping
Radoslaw Smogura
github.com+7535718+rsmogura at openjdk.java.net
Wed Sep 29 16:33:53 UTC 2021
On Tue, 28 Sep 2021 12:59:19 GMT, Julia Boes <jboes at openjdk.org> wrote:
> This change adds a method to the MemorySegment API that detects if two segments are overlapping.
src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java line 272:
> 270: final long thisEnd = thisStart + this.byteSize() - 1L;
> 271: final long thatEnd = thatStart + that.byteSize() - 1L;
> 272: if (thisStart < thatStart && thisEnd >= thatStart) {
Not sure if this is relevant, would it make sense to replace this checks by
`thisStart <= thatEnd && thisEnd >= thatStart`
I think it can be more performant.
Maybe we will be able to drop subtract of 1 and use strong equality
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/585
More information about the panama-dev
mailing list