[foreign-memaccess] RFR: Add MemorySegment::mismatch
mcimadamore at openjdk.java.net
Wed May 20 14:47:25 UTC 2020
On Wed, 20 May 2020 14:40:13 GMT, Chris Hegarty <chegar at openjdk.org> wrote:
>> src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java line 142:
>>> 142: this.checkRange(0, minSize, false);
>>> 143: that.checkRange(0, minSize, false);
>> This is of course correct but also a bit redundant (there's a similar issue, although to a smaller extent in
>> `copyFrom`). Let's see how performance numbers are - basically this code can be simplified by omitting the bound check
>> on both segments (since you already picked a size that must work on both) - so that we just need confinement + read
>> access check.
> Yeah, I did think this too at the time, but then forgot. How about I just add a private method `checkStateAndAccess`.
For now I think we can keep it as is, as it's cleaner and reuses existing abstractions. If this becomes a performance
problem going forward we can revisit.
More information about the panama-dev