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

Pattern.quote() incompatible with fast path in String.split()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      It's currently difficult to make the most of the String.split() fast path when dealing with delimiters that are not known ahead of time, and may be more than one character. `Pattern.quote()` uses Q/E escaping, so always emits a pattern that's unable to take the fast path, so in performance sensitive cases you wind up having to write code that's aware of of the fast path decide whether it's better to cache a pattern and use `Pattern.split()` or call `String.split()`.

      At least if `Pattern.quote` were to handle a single character delimiter in a way compatible with the fast path, it might simplify writing logic to decide whether `String.split()` or `Pattern.split()` is the more profitable path:

      https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/String.java#L3417-L3426


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: