Avoid redundant HashMap.containsKey call in Type1Font.expandAbbreviation

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 20
    • Affects Version/s: 17, 18, 19
    • Component/s: client-libs
    • 2d
    • b07

      In java 8, Map interface was enhances with many useful methods, which allow to avoid calling a few separate Map methods.
      One of such example is in sun.font.Type1Font#expandAbbreviation method:

          private String expandAbbreviation(String abbr) {
              if (styleAbbreviationsMapping.containsKey(abbr))
                              return styleAbbreviationsMapping.get(abbr);
              return abbr;
          }

      Instead we can just call
                 
              return styleAbbreviationsMapping.getOrDefault(abbr, abbr);

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

              Created:
              Updated:
              Resolved: