JDK-8242842 : Avoid reallocating name when checking for trailing slash in ZipFile.getEntryPos
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-04-15
  • Updated: 2020-04-27
  • Resolved: 2020-04-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b19Fixed
Related Reports
Relates :  
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.
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/3c31744af8eb User: redestad Date: 2020-04-15 17:01:44 +0000
15-04-2020

This is an optimization that is done properly in the native zip implementation, but wasn't ported over successfully to the Java implementation.
15-04-2020