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

(zipfs) Avoid redundant LinkedHashMap.containsKey call ZipFileSystem.makeParentDirs

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P5 P5
    • 21
    • None
    • core-libs
    • b18

      LinkedHashMap<IndexNode, IndexNode> ZipFileSystem.inodes contains only non-null values.

                  if (inodes.containsKey(lookup)) {
                      parent = inodes.get(lookup);
                      node.sibling = parent.child;
                      parent.child = node;
                      break;
                  }

      It means instead of separate containsKey+get calls, we can use single LinkedHashMap.get call and then compare result with null.
      Result code is a bit simpler and faster.

                  parent = inodes.get(lookup);
                  if (parent != null) {
                      node.sibling = parent.child;
                      parent.child = node;
                      break;
                  }

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

              Created:
              Updated:
              Resolved: