[PR] Optimize getEntry performance in ZipInputStreamZipEntrySo urce using O(1) case-insensitive lookups [poi]

kali834x (via GitHub) <[email protected]> Mon, 15 Jun 2026 04:57:08 -0000
Newsgroups gmane.comp.jakarta.poi.devel
Message-ID <[email protected]>
kali834x opened a new pull request, #1144:
URL: https://github.com/apache/poi/pull/1144

   Entry names are normalized and lowercased before being stored in the zipEntries map:
   
   name = IOUtils.normalizePath(name).toLowerCase(Locale.ROOT);
   
   However, getEntry() performs its initial lookup using a non-lowercased key:
   
   final ZipArchiveEntry ze = zipEntries.get(normalizedPath);
   
   As a result, lookups for mixed-case paths may miss the direct map lookup and fall back to a linear case-insensitive scan of all entries, degrading lookup performance from O(1) to O(N).
   
   Solution
   
   Apply the same normalization strategy during lookup:
   
   return zipEntries.get(normalizedPath.toLowerCase(Locale.ROOT));
   
   This makes lookup behavior consistent with key storage, restores O(1) retrieval, and removes the need for the fallback linear scan.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]