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 2020/10/08 22:21:32 UTC

[commons-io] branch master updated: Tiny performance improvements. (#163)

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 75b79c7  Tiny performance improvements. (#163)
75b79c7 is described below

commit 75b79c7203699abb83e5ed2ed398af65139ef064
Author: Michiel Kalkman <mi...@gmail.com>
AuthorDate: Fri Oct 9 00:21:21 2020 +0200

    Tiny performance improvements. (#163)
---
 src/main/java/org/apache/commons/io/FileUtils.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java
index 25177d9..cee1eb3 100644
--- a/src/main/java/org/apache/commons/io/FileUtils.java
+++ b/src/main/java/org/apache/commons/io/FileUtils.java
@@ -714,13 +714,15 @@ public class FileUtils {
         if (!srcDir.isDirectory()) {
             throw new IOException("Source '" + srcDir + "' exists but is not a directory");
         }
-        if (srcDir.getCanonicalPath().equals(destDir.getCanonicalPath())) {
+        final String srcDirCanonicalPath = srcDir.getCanonicalPath();
+        final String destDirCanonicalPath = destDir.getCanonicalPath();
+        if (srcDirCanonicalPath.equals(destDirCanonicalPath)) {
             throw new IOException("Source '" + srcDir + "' and destination '" + destDir + "' are the same");
         }
 
         // Cater for destination being directory within the source directory (see IO-141)
         List<String> exclusionList = null;
-        if (destDir.getCanonicalPath().startsWith(srcDir.getCanonicalPath())) {
+        if (destDirCanonicalPath.startsWith(srcDirCanonicalPath)) {
             final File[] srcFiles = filter == null ? srcDir.listFiles() : srcDir.listFiles(filter);
             if (srcFiles != null && srcFiles.length > 0) {
                 exclusionList = new ArrayList<>(srcFiles.length);