On Thu, 24 Jul 2025 14:50:07 GMT, Tatsunori Uchino <[email protected]> wrote:
> Adds `codePointCount()` overloads to `String`, `Character`,
> `(Abstract)StringBuilder`, and `StringBuffer` to make it possible to
> conveniently retrieve the length of a string as code points without extra
> boundary checks.
>
>
> if (superTremendouslyLongExpressionYieldingAString().codePointCount() >
> limit) {
> throw new Exception("exceeding length");
> }
>
>
> Is a CSR required to this change?
src/java.base/share/classes/java/lang/Character.java line 9969:
> 9967: int n = length;
> 9968: for (int i = 0; i < length; ) {
> 9969: if (isHighSurrogate(seq.charAt(i++)) && i < length &&
Imo this is quite hard to read, especially with `i++` inside of the if
statement. What do you think about changing it to this?
```java
for (int i = 0; i < length; i++) {
if (isHighSurrogate(seq.charAt(i)) &&
i+1 < length &&
isLowSurrogate(seq.charAt(i+1))) {
n--;
i++;
}
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26461#discussion_r2229676944