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

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

XMLWordPrintable

      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.

            redestad Claes Redestad
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: