RFR: 8321283: Reuse StringLatin1::equals in regionMatches

Claes Redestad redestad at openjdk.org
Wed Nov 26 20:14:08 UTC 2025


On Sat, 2 Dec 2023 16:56:22 GMT, Francesco Nigro <duke at openjdk.org> wrote:

> This improvement has been found on https://github.com/vert-x3/vertx-web/pull/2526.
> 
> It can potentially affect the existing ArraysSupport.mismatch caller code-path performance ie requires investigation.

General comments:
- Does this suggest an optimization opportunity to `ArraysSupport::mismatch`, or is the relative overhead due the inherent costs of finding the exact index in the mismatch? 
- This only optimize the case where we're comparing the entirety of both `String`s. How common is this in practice? It would be good to check a mixed benchmark where some inputs will use this fast path and others won't to assert that this doesn't have an unexpected negative impact from adding a few tests. 

The tests in `StringComparisons`, e.g. `regionMatchesRange` might be a bit naive in the sense that the offsets are constant, which perhaps unrealistically remove any overhead from the added tests in your patch here.

Filed: https://bugs.openjdk.org/browse/JDK-8321283

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

PR Comment: https://git.openjdk.org/jdk/pull/16933#issuecomment-1838984100
PR Comment: https://git.openjdk.org/jdk/pull/16933#issuecomment-1839029351


More information about the core-libs-dev mailing list