Repository: ant
Updated Branches:
  refs/heads/master 79c8cb54f -> cc41d3c16


Cleanup and more StringBuilders

Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/cc41d3c1
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/cc41d3c1
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/cc41d3c1

Branch: refs/heads/master
Commit: cc41d3c1611c3a091e489fc026b33afd02f7eaed
Parents: 79c8cb5
Author: Gintas Grigelionis <gin...@apache.org>
Authored: Fri Apr 6 19:34:17 2018 +0200
Committer: Gintas Grigelionis <gin...@apache.org>
Committed: Fri Apr 6 19:34:17 2018 +0200

----------------------------------------------------------------------
 src/main/org/apache/tools/ant/Project.java            |  4 ++--
 .../org/apache/tools/ant/filters/TokenFilter.java     |  1 -
 src/main/org/apache/tools/ant/taskdefs/Ant.java       |  2 +-
 src/main/org/apache/tools/ant/taskdefs/Sync.java      |  2 --
 .../apache/tools/ant/taskdefs/optional/net/FTP.java   | 14 ++++++--------
 .../ant/taskdefs/optional/net/FTPTaskMirrorImpl.java  | 14 ++++++--------
 6 files changed, 15 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/cc41d3c1/src/main/org/apache/tools/ant/Project.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/Project.java 
b/src/main/org/apache/tools/ant/Project.java
index 6540cd9..3c20e38 100644
--- a/src/main/org/apache/tools/ant/Project.java
+++ b/src/main/org/apache/tools/ant/Project.java
@@ -1830,8 +1830,8 @@ public class Project implements ResourceFactory {
         }
         final StringBuilder buf = new StringBuilder();
         for (String root : roots) {
-            buf.append((buf.length() == 0) ? "Build sequence for target(s) `"
-                    : ", `").append(root).append('\'');
+            buf.append((buf.length() > 0) ? ", `" : "Build sequence for 
target(s) `")
+                    .append(root).append('\'');
         }
         buf.append(" is ").append(ret);
         log(buf.toString(), MSG_VERBOSE);

http://git-wip-us.apache.org/repos/asf/ant/blob/cc41d3c1/src/main/org/apache/tools/ant/filters/TokenFilter.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/filters/TokenFilter.java 
b/src/main/org/apache/tools/ant/filters/TokenFilter.java
index 38ab9ec..a8d54ca 100644
--- a/src/main/org/apache/tools/ant/filters/TokenFilter.java
+++ b/src/main/org/apache/tools/ant/filters/TokenFilter.java
@@ -19,7 +19,6 @@ package org.apache.tools.ant.filters;
 
 import java.io.IOException;
 import java.io.Reader;
-import java.util.Enumeration;
 import java.util.Vector;
 
 import org.apache.tools.ant.BuildException;

http://git-wip-us.apache.org/repos/asf/ant/blob/cc41d3c1/src/main/org/apache/tools/ant/taskdefs/Ant.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Ant.java 
b/src/main/org/apache/tools/ant/taskdefs/Ant.java
index 5c7bce5..064856a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Ant.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Ant.java
@@ -376,7 +376,7 @@ public class Ant extends Task {
             antFile = file.getAbsolutePath();
 
             log("calling target(s) "
-                + (!locals.isEmpty() ? locals.toString() : "[default]")
+                + (locals.isEmpty() ? "[default]" : locals.toString())
                 + " in build file " + antFile, Project.MSG_VERBOSE);
             newProject.setUserProperty(MagicNames.ANT_FILE, antFile);
 

http://git-wip-us.apache.org/repos/asf/ant/blob/cc41d3c1/src/main/org/apache/tools/ant/taskdefs/Sync.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Sync.java 
b/src/main/org/apache/tools/ant/taskdefs/Sync.java
index e22e40e..32863c3 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Sync.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Sync.java
@@ -19,9 +19,7 @@
 package org.apache.tools.ant.taskdefs;
 
 import java.io.File;
-import java.util.Arrays;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.Map;

http://git-wip-us.apache.org/repos/asf/ant/blob/cc41d3c1/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java 
b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
index c23ffbc..dd485b6 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
@@ -27,9 +27,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.file.Files;
 import java.text.SimpleDateFormat;
-import java.util.Arrays;
 import java.util.Collection;
-import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -959,7 +957,7 @@ public class FTP extends Task implements FTPTaskConfig {
             private String getRelativePath(String currentPath, String 
currentRelativePath) {
                 List<String> pathElements = 
SelectorUtils.tokenizePath(getAbsolutePath(), remoteFileSep);
                 List<String> pathElements2 = 
SelectorUtils.tokenizePath(currentPath, remoteFileSep);
-                String relPath = currentRelativePath;
+                StringBuilder relPath = new StringBuilder(currentRelativePath);
                 final int size = pathElements.size();
                 for (int pcount = pathElements2.size(); pcount < size; 
pcount++) {
                     String currentElement = pathElements.get(pcount);
@@ -968,23 +966,23 @@ public class FTP extends Task implements FTPTaskConfig {
                     if (theFiles != null) {
                         theFile = getFile(theFiles, currentElement);
                     }
-                    if (relPath != null && !relPath.isEmpty()) {
-                        relPath += remoteFileSep;
+                    if (relPath.length() > 0) {
+                        relPath.append(remoteFileSep);
                     }
                     if (theFile == null) {
                         // hit a hidden file assume not a symlink
-                        relPath += currentElement;
+                        relPath.append(currentElement);
                         currentPath += remoteFileSep + currentElement;
                         log("Hidden file " + relPath
                             + " assumed to not be a symlink.",
                             Project.MSG_VERBOSE);
                     } else {
                         traversesSymlinks = traversesSymlinks || 
theFile.isSymbolicLink();
-                        relPath += theFile.getName();
+                        relPath.append(theFile.getName());
                         currentPath += remoteFileSep + theFile.getName();
                     }
                 }
-                return relPath;
+                return relPath.toString();
             }
 
             /**

http://git-wip-us.apache.org/repos/asf/ant/blob/cc41d3c1/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
----------------------------------------------------------------------
diff --git 
a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java 
b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
index 631e73b..1e0b5f2 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
@@ -27,8 +27,6 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.file.Files;
 import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -861,7 +859,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                     .tokenizePath(getAbsolutePath(), task.getSeparator());
                 List<String> pathElements2 = SelectorUtils
                     .tokenizePath(currentPath, task.getSeparator());
-                String relPath = currentRelativePath;
+                StringBuilder relPath = new StringBuilder(currentRelativePath);
                 final int size = pathElements.size();
                 for (int pcount = pathElements2.size(); pcount < size; 
pcount++) {
                     String currentElement = pathElements.get(pcount);
@@ -870,23 +868,23 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                     if (theFiles != null) {
                         theFile = getFile(theFiles, currentElement);
                     }
-                    if (relPath != null && !relPath.isEmpty()) {
-                        relPath += task.getSeparator();
+                    if (relPath.length() > 0) {
+                        relPath.append(task.getSeparator());
                     }
                     if (theFile == null) {
                         // hit a hidden file assume not a symlink
-                        relPath += currentElement;
+                        relPath.append(currentElement);
                         currentPath += task.getSeparator() + currentElement;
                         task.log("Hidden file " + relPath
                                  + " assumed to not be a symlink.",
                                  Project.MSG_VERBOSE);
                     } else {
                         traversesSymlinks = traversesSymlinks || 
theFile.isSymbolicLink();
-                        relPath += theFile.getName();
+                        relPath.append(theFile.getName());
                         currentPath += task.getSeparator() + theFile.getName();
                     }
                 }
-                return relPath;
+                return relPath.toString();
             }
 
             /**

Reply via email to