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

Use optimized Ques node for curly {0,1} quantifier

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 15
    • None
    • core-libs
    • None

      The java.regex.Pattern engine has an optimized node Ques to represent the quantifier of type 'X?'.
      It would be beneficial, if the same optimized node was used for 'X{0,1}', which is essentially the same.

      Currently, a less efficient construct is used for the later expression:

      $java java.util.regex.PrintPattern 'X?'
         Pattern: X?
           0: <Start>
           1: <Ques GREEDY>
           2: <BmpCharProperty>
               </Ques>
           3: <END>

      $java java.util.regex.PrintPattern 'X{0,1}'
         Pattern: X{0,1}
           0: <Start>
           1: <Curly GREEDY {0, 1}>
           2: <BmpCharProperty>
               </Curly>
           3: <END>

            igerasim Ivan Gerasimov
            igerasim Ivan Gerasimov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: