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

Avoid redundant HashMap.containsKey calls in ZoneInfoFile.getZoneInfo0

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P5 P5
    • 19
    • None
    • core-libs

      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.util.calendar.ZoneInfoFile#getZoneInfo0 method:

                  String zid = zoneId;
                  if (aliases.containsKey(zoneId)) {
                      zid = aliases.get(zoneId);
                  }

      Instead we can just call
                 
                 aliases.getOrDefault(zoneId, zoneId)

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

              Created:
              Updated:
              Resolved: