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

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P5
    • 21
    • Affects Version/s: None
    • Component/s: 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;
                  }

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

              Created:
              Updated:
              Resolved: