kvr000 commented on code in PR #378:
URL: https://github.com/apache/commons-compress/pull/378#discussion_r1438946469


##########
src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java:
##########
@@ -368,9 +369,14 @@ public static void closeQuietly(final ZipFile zipFile) {
     private final List<ZipArchiveEntry> entries = new LinkedList<>();
 
     /**
-     * Maps String to list of ZipArchiveEntrys, name -> actual entries.
+     * Maps a string to the first entry by that name.
      */
-    private final Map<String, LinkedList<ZipArchiveEntry>> nameMap = new 
HashMap<>(HASH_SIZE);
+    private final Map<String, ZipArchiveEntry> nameMap = new 
HashMap<>(HASH_SIZE);
+
+    /**
+     * If multiple entries have the same name, maps the name to entries by 
that name.
+     */
+    private Map<String, List<ZipArchiveEntry>> duplicateNameMap;

Review Comment:
   That's true, such optimizations typically come at cost of readability and 
safety.  However, keeping the amount of code touching the data structures 
limited may help - we'll need only three methods - `first-by-name`, 
`all-by-name` and `add-entry` .  And document the field to not touch except via 
those three methods :-)
   
   Just a suggestion if it comes to true optimization, given this PR is purely 
about improving time and space performance.



-- 
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]

Reply via email to