[foreign-memaccess+abi] RFR: 8274157: java.foreign: Add method MemorySegment::asOverlappingSlice [v3]

Radoslaw Smogura github.com+7535718+rsmogura at openjdk.java.net
Mon Oct 4 18:54:23 UTC 2021


On Mon, 4 Oct 2021 12:57:00 GMT, Julia Boes <jboes at openjdk.org> wrote:

>> This change adds a method to the MemorySegment API that detects if two segments are overlapping.
>
> Julia Boes has updated the pull request incrementally with one additional commit since the last revision:
> 
>   add test for overlap and offsetOf and update names

src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java line 263:

> 261:             final long thatEnd = thatStart + that.byteSize() - 1L;
> 262: 
> 263:             if (thisStart <= thatEnd && thisEnd >= thatStart) {  //overlap occurs

Hi,

Minor, I wonder if it would make sense to replace "weak" inequality with strong inequality and remove subtraction of 1 (two instructs less)?

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

PR: https://git.openjdk.java.net/panama-foreign/pull/585


More information about the panama-dev mailing list