commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [commons-compress] branch master updated: Performance Improvement: Call toArray with 0 Array Size
Date Tue, 18 Jun 2019 09:47:25 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new f925a0c  Performance Improvement: Call toArray with 0 Array Size
     new e912631  Merge pull request #81 from DaGeRe/master
f925a0c is described below

commit f925a0c62a74199b0869614f7a266297af26dc3b
Author: David Georg Reichelt <davidgeorg_reichelt@dagere.de>
AuthorDate: Mon Jun 17 21:17:12 2019 +0200

    Performance Improvement: Call toArray with 0 Array Size
---
 .../apache/commons/compress/archivers/arj/ArjArchiveInputStream.java  | 2 +-
 .../apache/commons/compress/archivers/sevenz/SevenZOutputFile.java    | 2 +-
 .../org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java    | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
b/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
index 688f5e0..089f906 100644
--- a/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
@@ -261,7 +261,7 @@ public class ArjArchiveInputStream extends ArchiveInputStream {
                     }
                     extendedHeaders.add(extendedHeaderBytes);
                 }
-                localFileHeader.extendedHeaders = extendedHeaders.toArray(new byte[extendedHeaders.size()][]);
+                localFileHeader.extendedHeaders = extendedHeaders.toArray(new byte[0][]);
 
                 return localFileHeader;
             }
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
index c95da10..75f8867 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
@@ -322,7 +322,7 @@ public class SevenZOutputFile implements Closeable {
             first = false;
         }
         if (!moreStreams.isEmpty()) {
-            additionalCountingStreams = moreStreams.toArray(new CountingOutputStream[moreStreams.size()]);
+            additionalCountingStreams = moreStreams.toArray(new CountingOutputStream[0]);
         }
         return new CountingOutputStream(out) {
             @Override
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 564e5a7..55ac51c 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
@@ -411,7 +411,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
                 newFields.add( field);
             }
         }
-        extraFields = newFields.toArray(new ZipExtraField[newFields.size()]);
+        extraFields = newFields.toArray(new ZipExtraField[0]);
         setExtra();
     }
 
@@ -560,7 +560,7 @@ public class ZipArchiveEntry extends java.util.zip.ZipEntry
         if (extraFields.length == newResult.size()) {
             throw new java.util.NoSuchElementException();
         }
-        extraFields = newResult.toArray(new ZipExtraField[newResult.size()]);
+        extraFields = newResult.toArray(new ZipExtraField[0]);
         setExtra();
     }
 


Mime
View raw message