You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2016/04/10 06:18:41 UTC
[25/46] commons-compress git commit: [COMPRESS-350] TarArchiveEntry
wastefully allocates empty arrays.
[COMPRESS-350] TarArchiveEntry wastefully allocates empty arrays.
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/9cc0604f
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/9cc0604f
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/9cc0604f
Branch: refs/heads/COMPRESS-207
Commit: 9cc0604f7fdab2b23ead5f72a93feb2196660736
Parents: ab17a70
Author: ggregory <gg...@apache.org>
Authored: Sat Apr 9 09:10:36 2016 -0700
Committer: ggregory <gg...@apache.org>
Committed: Sat Apr 9 09:10:36 2016 -0700
----------------------------------------------------------------------
src/changes/changes.xml | 5 ++++-
.../commons/compress/archivers/tar/TarArchiveEntry.java | 9 +++++++--
2 files changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/9cc0604f/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 86527c7..8632ce0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -44,9 +44,12 @@ The <action> type attribute can be add,update,fix,remove.
<body>
<release version="1.12" date="not released, yet"
description="Release 1.12">
- <action issue="COMPRESS-349" type="update" date="2016-04-09">
+ <action issue="COMPRESS-349" type="update" date="2016-04-09" dev="ggregory">
Update requirement from Java 5 to 6.
</action>
+ <action issue="COMPRESS-350" type="update" date="2016-04-09" dev="ggregory">
+ TarArchiveEntry wastefully allocates empty arrays.
+ </action>
</release>
<release version="1.11" date="2016-04-06"
description="Release 1.11">
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/9cc0604f/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
index 4fac7d5..00a3edd 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
@@ -143,6 +143,8 @@ import org.apache.commons.compress.utils.ArchiveUtils;
*/
public class TarArchiveEntry implements TarConstants, ArchiveEntry {
+ private static final TarArchiveEntry[] EMPTY_TAR_ARCHIVE_ENTRIES = new TarArchiveEntry[0];
+
/** The entry's name. */
private String name = "";
@@ -945,11 +947,14 @@ public class TarArchiveEntry implements TarConstants, ArchiveEntry {
*/
public TarArchiveEntry[] getDirectoryEntries() {
if (file == null || !file.isDirectory()) {
- return new TarArchiveEntry[0];
+ return EMPTY_TAR_ARCHIVE_ENTRIES;
}
String[] list = file.list();
- TarArchiveEntry[] result = new TarArchiveEntry[list == null ? 0 : list.length];
+ if (list == null) {
+ return EMPTY_TAR_ARCHIVE_ENTRIES;
+ }
+ TarArchiveEntry[] result = new TarArchiveEntry[list.length];
for (int i = 0; i < result.length; ++i) {
result[i] = new TarArchiveEntry(new File(file, list[i]));