Glavo commented on code in PR #378:
URL: https://github.com/apache/commons-compress/pull/378#discussion_r1188942199
##########
src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java:
##########
@@ -899,13 +921,17 @@ public Enumeration<ZipArchiveEntry>
getEntriesInPhysicalOrder() {
* @since 1.6
*/
public Iterable<ZipArchiveEntry> getEntriesInPhysicalOrder(final String
name) {
- ZipArchiveEntry[] entriesOfThatName = ZipArchiveEntry.EMPTY_ARRAY;
- final LinkedList<ZipArchiveEntry> linkedList = nameMap.get(name);
- if (linkedList != null) {
- entriesOfThatName = linkedList.toArray(entriesOfThatName);
- Arrays.sort(entriesOfThatName, offsetComparator);
+ if (duplicateNameMap != null) {
+ List<ZipArchiveEntry> list = duplicateNameMap.get(name);
+ if (list != null) {
+ ZipArchiveEntry[] entriesOfThatName =
list.toArray(ZipArchiveEntry.EMPTY_ARRAY);
Review Comment:
> Instead of:
>
> 1. allocate array
> 2. sort array
> 3. allocate list
>
> would it be better to change the type from `List` to `LinkedList` (which
is what is used in the instance variable decl and:
>
> 1. `clone()` the list
> 2. `Collections.sort()` the cloned list
>
> ?
I think it might be cleaner to keep it as it is now.
The return type of the `clone` method of `ArrayList`/`LinkedList` is
`Object`, which means that after calling it, a cast is required and
`SuppressWarnings` annotation is required to suppress unchecked warnings.
--
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]