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

(cs) Avoid redundant TreeMap.containsKey call in AbstractCharsetProvider

XMLWordPrintable

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

      The method sun.nio.cs.ext.AbstractCharsetProvider#put is effectively equivalent of Map.putIfAbsent call.

          private static <K,V> void put(Map<K,V> m, K name, V value) {
              if (!m.containsKey(name))
                  m.put(name, value);
          }

      Instead of hand-written method we can use 'putIfAbsent' directly.
      I makes code cleaner and gives a bit of performance.

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

              Created:
              Updated:
              Resolved: