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

Avoid redundant HashMap.containsKey call in Type1Font.expandAbbreviation

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 20
    • 17, 18, 19
    • 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);

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

              Created:
              Updated:
              Resolved: