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

Add support for StringBuilder to java.util.regex.Matcher

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 6u10
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      A DESCRIPTION OF THE REQUEST :
      There appears to be an unfortunate JDK1.4 historical artifact of using StringBuffer in the method signatures of appendReplacement and appendTail in the java.util.regex.Matcher class. Adding alternate methods that use java.lang.Appendable would allow for a wider choice of classes to be used with Matcher. Updating the internal use of StringBuffer to StringBuilder within Matcher itself would also increase its performance.

      JUSTIFICATION :
      The slow performance of StringBuffer is well known. JDK 1.5 introduced StringBuilder as a drop in replacement. At that time the interface java.lang.Appendable was introduced. Using Appendable is in the method signature as well as using StringBuilder within the replaceFirst, replaceAll and appendReplacment methods should dramatically increase the performance of Matcher.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Same behavior with better performance and increased flexibility.
      ACTUAL -
      Same behavior with slow performance.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sherman Xueming Shen
                Reporter:
                ndcosta Nelson Dcosta (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: