RFR: 8323552: AbstractMemorySegmentImpl#mismatch returns -1 when comparing distinct areas of the same instance of MemorySegment [v2]
Peter Levart
plevart at openjdk.org
Thu Jan 11 16:21:40 UTC 2024
On Thu, 11 Jan 2024 15:23:14 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> Peter Levart has updated the pull request incrementally with one additional commit since the last revision:
>>
>> move special-case check for equal segments to the instance method (more probable)
>
> src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java line 299:
>
>> 297: checkValidState();
>> 298: return -1;
>> 299: }
>
> I'm skeptical of trying to optimize this without a more thorough performance investigation. We shouldn't add this complexity on a whim.
>
> I'm more in favor of just dropping the check from the static mismatch method and leaving it at that. (And adding a test as Maurizio mentioned).
I have similar thoughts. This is low-level API. Code using it has more context knowledge and is more fit to do optimisations like that or not, depending if they are worth it. I would want such low level API to do as little checks as possible to accommodate faster common case scenario.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17354#discussion_r1449093606
More information about the core-libs-dev
mailing list