On Fri, 5 Jun 2026 16:54:13 GMT, Justin Lu <[email protected]> wrote: >> Naoto Sato has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Reflects review comments > > src/java.base/share/classes/java/text/ListFormat.java line 744: > >> 742: */ >> 743: private static boolean validatePlaceholders(String pattern) { >> 744: for (int i = 0; i < pattern.length(); i++) { > > Since `validatePlaceholders` already iterates through the entire pattern > string to validate braces, I think we can just merge the logic of > `findPlaceholders` and `validatePlaceholders` into this main loop to do > validation and placeholder recording. > > Instead of > > > var positions = new int[3]; > for (int i = 0; i < positions.length; i++) { > var ph = "{" + i + "}"; > positions[i] = pattern.indexOf(ph); > if (positions[i] >= 0) { > // Check for duplicate placeholders > if (pattern.indexOf(ph, positions[i] + PLACEHOLDER_LENGTH) >= > 0) { > return null; > } > } > } > > > I think we can just initialize `positions` as `new int[] {-1, -1, -1};` and > if `positions[index] != -1` we can fail. We can derive the correct `index` > via `pattern.charAt(i + 1) - '0'` (given this code occurs within the `ch == > '{'` block).
Yes. That'd be simpler/performant. Fixed. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/31377#discussion_r3364344972
