RFR: 8297561: Redundant index check in String.offsetByCodePoints()
Sergey Tsypanov
stsypanov at openjdk.org
Wed Nov 30 18:19:53 UTC 2022
On Thu, 24 Nov 2022 10:08:31 GMT, Sergey Tsypanov <stsypanov at openjdk.org> wrote:
> `String.offsetByCodePoints()` delegates to `Character.offsetByCodePoints()` which in turn specifies the same exception thrown under the same conditions and the implementation does exactly the same checks. This means we can remove the check from `String.offsetByCodePoints()` and rely on the one of `Character.offsetByCodePoints()`.
I've added a benchmark for the changes, on my machine it gives the following results:
baseline
Benchmark Mode Cnt Score Error Units
StringOffsetByCodePoints.offsetByCodePoints avgt 30 6.616 ± 0.040 ns/op
patch
Benchmark Mode Cnt Score Error Units
StringOffsetByCodePoints.offsetByCodePoints avgt 30 6.606 ± 0.008 ns/op
-------------
PR: https://git.openjdk.org/jdk/pull/11350
More information about the core-libs-dev
mailing list