Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8302590

Add String.indexOf(int ch, int fromIndex, int toIndex)

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 21
    • 8, 11, 17, 19, 20
    • core-libs
    • 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`.

            rgiulietti Raffaello Giulietti
            rgiulietti Raffaello Giulietti
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: