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

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 21
    • Affects Version/s: 8, 11, 17, 19, 20
    • Component/s: 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`.

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

              Created:
              Updated:
              Resolved: