RFR: 8271732: Regression in StringBuilder.charAt bounds checking [v2]

Claes Redestad redestad at openjdk.java.net
Wed Aug 11 20:15:11 UTC 2021


> In #4738 we removed the `checkIndex(value, count)` call in `ASB.charAt` to avoid potentially getting two bounds checks in the UTF-16 case. Problem is this optimization cause a regression since `StringUTF16.charAt(..)` checks `index` against the length of the `value` array and not `count`.
> 
> A correct fix that still maintain the possible performance advantage reported by #4738 is to reinstate the `checkIndex(value, count)` and call `StringUTF16.getChar` instead of `charAt`.

Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:

  Add SB.charAt test

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/5086/files
  - new: https://git.openjdk.java.net/jdk/pull/5086/files/e72d9e15..e29c576a

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=5086&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=5086&range=00-01

  Stats: 66 lines in 1 file changed: 66 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/5086.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/5086/head:pull/5086

PR: https://git.openjdk.java.net/jdk/pull/5086


More information about the core-libs-dev mailing list