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

Lightweight implementation of String.split for simple use case

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 7
    • 7
    • core-libs
    • b71
    • generic
    • generic

      String.split(regex, limit) uses regex as the implementation and returns java.util.regex.Pattern.compile(regex).split(this, limit).

      A simple use of String.split (e.g. the regex is just one character-delimiter) will need to initialize the regex engine and load many regex classes that is pretty heavy-weight.

      Most of the String.split calls from the JRE implementation are the simple case e.g. regex parameter is "=", ":", ",", "\0", "\\|"

      We can implement a lightweight version of String.split for these simple regex to avoid loading the regex engine. Alternatively, if feasible, implement a lightweight version of the regex support so that String.replaceAll, String.replaceFirst, String.replace(CharSequence, CharSequence), and String.matches can take advantage of such optimization.

            sherman Xueming Shen
            mchung Mandy Chung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: