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

Avoid redundant HashMap.containsKey call in java.util.zip.ZipFile.Source.get

XMLWordPrintable

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

      We can use single putIfAbsent instead of separate containsKey/get/put calls.
      It makes code a bit cleaner and faster.

                  synchronized (files) {
                      if (files.containsKey(key)) {
                          src.close();
                          src = files.get(key);
                          src.refs++;
                          return src;
                      }
                      files.put(key, src);
                      return src;
                  }

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

              Created:
              Updated:
              Resolved: