On 10/1/21 1:57 PM, Brett Okken wrote: > I know java.lang.StringCoding.hasNegatives has a > HotSpotIntrinsicCandidate annotation/implementation, but is there > interest/value in a faster pure java implementation? > > Using Unsafe to read and compare 8 bytes at a time as a long is faster > than the current simple implementation both in interpreter only mode > and default hotspot compiler mode. I can provide jmh bencmark and > results if this is worthwhile to pursue.
The current pure Java implementation does two things: it provides a fallback for pure-interpreter JVMs and it provides the reader with a simple implementation. I'm not at all sure we'd want a complex implementation. Having said that, if I were looking at a faster pure Java version of this logic, I'd look at MethodHandles.byteArrayViewVarHandle(). -- Andrew Haley (he/him) Java Platform Lead Engineer Red Hat UK Ltd. <https://www.redhat.com> https://keybase.io/andrewhaley EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671