You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/11/30 12:37:22 UTC

[commons-compress] branch master updated (e1a9fc5f -> dda88755)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git


    from e1a9fc5f Javadoc
     new f90fbb46 Use Map API
     new 724cbfa9 Simpler package private name
     new dda88755 Use Map API

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/commons/compress/archivers/zip/ZipArchiveEntry.java   | 7 +++----
 .../java/org/apache/commons/compress/archivers/zip/ZipFile.java  | 9 +++++----
 .../org/apache/commons/compress/compressors/FileNameUtil.java    | 4 +---
 .../harmony/unpack200/SegmentConstantPoolArrayCache.java         | 4 +---
 4 files changed, 10 insertions(+), 14 deletions(-)


[commons-compress] 02/03: Simpler package private name

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 724cbfa9b5f25a884c7bb8dc85e2e8b96f6f1db2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Nov 30 07:32:39 2022 -0500

    Simpler package private name
    
    Only look up name once
---
 .../apache/commons/compress/archivers/zip/ZipArchiveEntry.java   | 7 +++----
 .../java/org/apache/commons/compress/archivers/zip/ZipFile.java  | 9 +++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
index 0186f4ab..706e5020 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
@@ -55,9 +55,9 @@ import org.apache.commons.compress.utils.ByteUtils;
  *
  * @NotThreadSafe
  */
-public class ZipArchiveEntry extends java.util.zip.ZipEntry
-    implements ArchiveEntry, EntryStreamOffsets
-{
+public class ZipArchiveEntry extends java.util.zip.ZipEntry implements ArchiveEntry, EntryStreamOffsets {
+
+    static final ZipArchiveEntry[] EMPTY_ARRAY = {};
 
     public static final int PLATFORM_UNIX = 3;
     public static final int PLATFORM_FAT  = 0;
@@ -149,7 +149,6 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
     private NameSource nameSource = NameSource.NAME;
     private CommentSource commentSource = CommentSource.COMMENT;
     private long diskNumberStart;
-    static final ZipArchiveEntry[] EMPTY_ZIP_ARCHIVE_ENTRY_ARRAY = {};
 
     /**
      * Creates a new zip entry with the specified name.
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
index f06245da..df18dd41 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
@@ -507,7 +507,7 @@ public class ZipFile implements Closeable {
      * @since 1.1
      */
     public Enumeration<ZipArchiveEntry> getEntriesInPhysicalOrder() {
-        final ZipArchiveEntry[] allEntries = entries.toArray(ZipArchiveEntry.EMPTY_ZIP_ARCHIVE_ENTRY_ARRAY);
+        final ZipArchiveEntry[] allEntries = entries.toArray(ZipArchiveEntry.EMPTY_ARRAY);
         Arrays.sort(allEntries, offsetComparator);
         return Collections.enumeration(Arrays.asList(allEntries));
     }
@@ -554,9 +554,10 @@ public class ZipFile implements Closeable {
      * @since 1.6
      */
     public Iterable<ZipArchiveEntry> getEntriesInPhysicalOrder(final String name) {
-        ZipArchiveEntry[] entriesOfThatName = ZipArchiveEntry.EMPTY_ZIP_ARCHIVE_ENTRY_ARRAY;
-        if (nameMap.containsKey(name)) {
-            entriesOfThatName = nameMap.get(name).toArray(entriesOfThatName);
+        ZipArchiveEntry[] entriesOfThatName = ZipArchiveEntry.EMPTY_ARRAY;
+        final LinkedList<ZipArchiveEntry> linkedList = nameMap.get(name);
+        if (linkedList != null) {
+            entriesOfThatName = linkedList.toArray(entriesOfThatName);
             Arrays.sort(entriesOfThatName, offsetComparator);
         }
         return Arrays.asList(entriesOfThatName);


[commons-compress] 03/03: Use Map API

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit dda8875584a35a1dd543f39909964fb0436c68d5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Nov 30 07:37:16 2022 -0500

    Use Map API
---
 .../java/org/apache/commons/compress/compressors/FileNameUtil.java    | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java b/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java
index ed948851..5d90f446 100644
--- a/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java
+++ b/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java
@@ -105,9 +105,7 @@ public class FileNameUtil {
             final String u = ent.getValue();
             final int ul = u.length();
             if (ul > 0) {
-                if (!compressSuffix.containsKey(u)) {
-                    compressSuffix.put(u, ent.getKey());
-                }
+                compressSuffix.computeIfAbsent(u, k -> ent.getKey());
                 if (ul > lu) {
                     lu = ul;
                 }


[commons-compress] 01/03: Use Map API

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit f90fbb46e86181e41100415c75aacd5591bec6ee
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Nov 30 07:24:38 2022 -0500

    Use Map API
---
 .../compress/harmony/unpack200/SegmentConstantPoolArrayCache.java     | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPoolArrayCache.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPoolArrayCache.java
index d5570da5..486e35d2 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPoolArrayCache.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/SegmentConstantPoolArrayCache.java
@@ -152,9 +152,7 @@ public class SegmentConstantPoolArrayCache {
         protected void cacheIndexes() {
             for (int index = 0; index < primaryArray.length; index++) {
                 final String key = primaryArray[index];
-                if (!primaryTable.containsKey(key)) {
-                    primaryTable.put(key, new ArrayList<>());
-                }
+                primaryTable.computeIfAbsent(key, k -> new ArrayList<>());
                 primaryTable.get(key).add(Integer.valueOf(index));
             }
         }