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

Avoid redundant HashMap.containsKey call in java.util.regex

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P5
    • 21
    • None
    • core-libs

    Description

      Pattern.namedGroups and Matcher.namedGroups contains only non-null values. It means instead of separate containsKey+get calls, we can use single HashMap.get call and then compare result with null.
      Result code is a bit simpler and faster.

      Affected methods:
      1. java.util.regex.Matcher#getMatchedGroupIndex
      2. java.util.regex.Pattern#escape
      3. java.util.regex.Matcher#appendExpandedReplacement

      Attachments

        Issue Links

          Activity

            People

              aturbanov Andrey Turbanov
              aturbanov Andrey Turbanov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: