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 2019/12/25 16:42:50 UTC

[commons-io] branch master updated: No need to allocate empty File arrays over and over.

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-io.git


The following commit(s) were added to refs/heads/master by this push:
     new d6324ee  No need to allocate empty File arrays over and over.
d6324ee is described below

commit d6324eeee9728294f7adda887d033c860d294d9c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Dec 25 11:42:47 2019 -0500

    No need to allocate empty File arrays over and over.
---
 .../java/org/apache/commons/io/filefilter/FileFilterUtils.java     | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/filefilter/FileFilterUtils.java b/src/main/java/org/apache/commons/io/filefilter/FileFilterUtils.java
index c654ecd..b94c537 100644
--- a/src/main/java/org/apache/commons/io/filefilter/FileFilterUtils.java
+++ b/src/main/java/org/apache/commons/io/filefilter/FileFilterUtils.java
@@ -27,6 +27,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOCase;
 
 /**
@@ -78,7 +79,7 @@ public class FileFilterUtils {
             throw new IllegalArgumentException("file filter is null");
         }
         if (files == null) {
-            return new File[0];
+            return FileUtils.EMPTY_FILE_ARRAY;
         }
         final List<File> acceptedFiles = new ArrayList<>();
         for (final File file : files) {
@@ -89,7 +90,7 @@ public class FileFilterUtils {
                 acceptedFiles.add(file);
             }
         }
-        return acceptedFiles.toArray(new File[0]);
+        return acceptedFiles.toArray(FileUtils.EMPTY_FILE_ARRAY);
     }
 
     /**
@@ -120,7 +121,7 @@ public class FileFilterUtils {
      */
     public static File[] filter(final IOFileFilter filter, final Iterable<File> files) {
         final List<File> acceptedFiles = filterList(filter, files);
-        return acceptedFiles.toArray(new File[0]);
+        return acceptedFiles.toArray(FileUtils.EMPTY_FILE_ARRAY);
     }
 
     /**