On Fri, 2 Feb 2024 13:54:46 GMT, Claes Redestad <redes...@openjdk.org> wrote:
> This patch streamlines and specializes various `String::indexOf` methods. > Mainly avoids the need for clamping and doing checks that are redundant in > almost all cases, moving the checks to the API boundary where they are > needed. > > This improves performance both at peak and during startup/warmup. Since > indexOf is heavily used in bootstrapping code it makes sense to slightly dial > back abstraction and delegation, which in this case also brought some benefit > to peak performance. > > Testing: tier1-3 src/java.base/share/classes/java/lang/StringLatin1.java line 1: > 1: /* L.313 What about a comment stating that the method expects `fromIndex >= 0`? Albeit on a package private class, it is still a `public` method, so stating preconditions helps. Similarly for the `StringUTF16` case. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/17685#discussion_r1476322233