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

Avoid reallocating name when checking for trailing slash in ZipFile.getEntryPos

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 15
    • Component/s: core-libs

      Description

      getEntryPos does this:

                      /* Add slash and try once more */
                      name = Arrays.copyOf(name, name.length + 1);
                      name[name.length - 1] = '/';
                      hsh = hash_append(hsh, (byte)'/');

      A trivial optimization to ZipFile.getEntryPos would be to only copy the name array after finding a match for the re-calculated hash value. This removes an allocation and array copy on every miss.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                redestad Claes Redestad
                Reporter:
                redestad Claes Redestad
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: