Browse Source

Cleanup and more StringBuilders

master
Gintas Grigelionis 7 years ago
parent
commit
cc41d3c161
6 changed files with 15 additions and 22 deletions
  1. +2
    -2
      src/main/org/apache/tools/ant/Project.java
  2. +0
    -1
      src/main/org/apache/tools/ant/filters/TokenFilter.java
  3. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Ant.java
  4. +0
    -2
      src/main/org/apache/tools/ant/taskdefs/Sync.java
  5. +6
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  6. +6
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java

+ 2
- 2
src/main/org/apache/tools/ant/Project.java View File

@@ -1830,8 +1830,8 @@ public class Project implements ResourceFactory {
} }
final StringBuilder buf = new StringBuilder(); final StringBuilder buf = new StringBuilder();
for (String root : roots) { 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); buf.append(" is ").append(ret);
log(buf.toString(), MSG_VERBOSE); log(buf.toString(), MSG_VERBOSE);


+ 0
- 1
src/main/org/apache/tools/ant/filters/TokenFilter.java View File

@@ -19,7 +19,6 @@ package org.apache.tools.ant.filters;


import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
import java.util.Enumeration;
import java.util.Vector; import java.util.Vector;


import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Ant.java View File

@@ -376,7 +376,7 @@ public class Ant extends Task {
antFile = file.getAbsolutePath(); antFile = file.getAbsolutePath();


log("calling target(s) " log("calling target(s) "
+ (!locals.isEmpty() ? locals.toString() : "[default]")
+ (locals.isEmpty() ? "[default]" : locals.toString())
+ " in build file " + antFile, Project.MSG_VERBOSE); + " in build file " + antFile, Project.MSG_VERBOSE);
newProject.setUserProperty(MagicNames.ANT_FILE, antFile); newProject.setUserProperty(MagicNames.ANT_FILE, antFile);




+ 0
- 2
src/main/org/apache/tools/ant/taskdefs/Sync.java View File

@@ -19,9 +19,7 @@
package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import java.io.File; import java.io.File;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Map; import java.util.Map;


+ 6
- 8
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

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


/** /**


+ 6
- 8
src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java View File

@@ -27,8 +27,6 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@@ -861,7 +859,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
.tokenizePath(getAbsolutePath(), task.getSeparator()); .tokenizePath(getAbsolutePath(), task.getSeparator());
List<String> pathElements2 = SelectorUtils List<String> pathElements2 = SelectorUtils
.tokenizePath(currentPath, task.getSeparator()); .tokenizePath(currentPath, task.getSeparator());
String relPath = currentRelativePath;
StringBuilder relPath = new StringBuilder(currentRelativePath);
final int size = pathElements.size(); final int size = pathElements.size();
for (int pcount = pathElements2.size(); pcount < size; pcount++) { for (int pcount = pathElements2.size(); pcount < size; pcount++) {
String currentElement = pathElements.get(pcount); String currentElement = pathElements.get(pcount);
@@ -870,23 +868,23 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
if (theFiles != null) { if (theFiles != null) {
theFile = getFile(theFiles, currentElement); theFile = getFile(theFiles, currentElement);
} }
if (relPath != null && !relPath.isEmpty()) {
relPath += task.getSeparator();
if (relPath.length() > 0) {
relPath.append(task.getSeparator());
} }
if (theFile == null) { if (theFile == null) {
// hit a hidden file assume not a symlink // hit a hidden file assume not a symlink
relPath += currentElement;
relPath.append(currentElement);
currentPath += task.getSeparator() + currentElement; currentPath += task.getSeparator() + currentElement;
task.log("Hidden file " + relPath task.log("Hidden file " + relPath
+ " assumed to not be a symlink.", + " assumed to not be a symlink.",
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
} else { } else {
traversesSymlinks = traversesSymlinks || theFile.isSymbolicLink(); traversesSymlinks = traversesSymlinks || theFile.isSymbolicLink();
relPath += theFile.getName();
relPath.append(theFile.getName());
currentPath += task.getSeparator() + theFile.getName(); currentPath += task.getSeparator() + theFile.getName();
} }
} }
return relPath;
return relPath.toString();
} }


/** /**


Loading…
Cancel
Save