-
Enhancement
-
Resolution: Fixed
-
P4
-
8, 11, 17, 19, 20
-
b13
`String` currently exposes `indexOf(int ch)` and `indexOf(int ch, int fromIndex)`. In both cases, the upper limit for the search is implicitly the length of the target string. Sometimes this is too much, in particular when the character `ch` does not occur in the target `String`.
The implementations end up invoking internal methods supporting an explicit `int` argument `toIndex` to limit the search to positions with indices in the half-open range [`fromIndex`, `toIndex`). These internal methods are intrinsifed, and make use of SIMD instruction, where available, to considerably speed up the search.
Class `String` does not expose a method `indexOf(int ch, int fromIndex, int toIndex)`, with an explicit upper limit for the search. Since the underlying implementations already exist, it would be beneficial to add this method to `String`.
The implementations end up invoking internal methods supporting an explicit `int` argument `toIndex` to limit the search to positions with indices in the half-open range [`fromIndex`, `toIndex`). These internal methods are intrinsifed, and make use of SIMD instruction, where available, to considerably speed up the search.
Class `String` does not expose a method `indexOf(int ch, int fromIndex, int toIndex)`, with an explicit upper limit for the search. Since the underlying implementations already exist, it would be beneficial to add this method to `String`.
- csr for
-
JDK-8302680 Add String.indexOf(int ch, int fromIndex, int toIndex)
- Closed
- relates to
-
JDK-8303648 Add String.indexOf(String str, int beginIndex, int endIndex)
- Resolved