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

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P5
    • 21
    • Affects Version/s: None
    • Component/s: core-libs

      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

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

              Created:
              Updated:
              Resolved: