Browse Source

assorted micro-optimizations by Adrian Nistor - 13 different Bugzilla issues

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1554813 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 11 years ago
parent
commit
326b38f701
10 changed files with 37 additions and 12 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +4
    -0
      contributors.xml
  3. +1
    -1
      src/main/org/apache/tools/ant/ComponentHelper.java
  4. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java
  5. +4
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  6. +4
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
  7. +1
    -1
      src/main/org/apache/tools/ant/util/FileUtils.java
  8. +18
    -0
      src/main/org/apache/tools/ant/util/IdentityStack.java
  9. +1
    -1
      src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
  10. +2
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java

+ 1
- 0
CONTRIBUTORS View File

@@ -3,6 +3,7 @@ Amongst other, the following people contributed to ant:
Adam Blinkinsop
Adam Bryzak
Adam Sotona
Adrian Nistor
Aleksandr Ishutin
Alex Rosen
Alexei Yudichev


+ 4
- 0
contributors.xml View File

@@ -42,6 +42,10 @@
<first>Adam</first>
<last>Sotona</last>
</name>
<name>
<first>Adrian</first>
<last>Nistor</last>
</name>
<name>
<first>Aleksandr</first>
<last>Ishutin</last>


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

@@ -1017,7 +1017,7 @@ public class ComponentHelper {
* Print unknown definition.forking
*/
private void printUnknownDefinition(PrintWriter out, String componentName, String dirListing) {
boolean isAntlib = componentName.indexOf(MagicNames.ANTLIB_PREFIX) == 0;
boolean isAntlib = componentName.startsWith(MagicNames.ANTLIB_PREFIX);
String uri = ProjectHelper.extractUriFromComponentName(componentName);
out.println("Cause: The name is undefined.");
out.println("Action: Check the spelling.");


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java View File

@@ -156,7 +156,7 @@ public class FailureRecorder extends ProjectComponent implements JUnitResultForm
Object listener = allListeners.get(i);
if (listener instanceof FailureRecorder) {
alreadyRegistered = true;
continue;
break;
}
}
// register if needed


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

@@ -727,6 +727,7 @@ public class FTP extends Task implements FTPTaskConfig {
&& pcounter != icounter
&& target.equals(array[pcounter].getName())) {
candidateFound = false;
break;
}
}
if (candidateFound) {
@@ -908,7 +909,7 @@ public class FTP extends Task implements FTPTaskConfig {
*/
public String getFastRelativePath() {
String absPath = getAbsolutePath();
if (absPath.indexOf(rootPath + remoteFileSep) == 0) {
if (absPath.startsWith(rootPath + remoteFileSep)) {
return absPath.substring(rootPath.length() + remoteFileSep.length());
}
return null;
@@ -2356,13 +2357,13 @@ public class FTP extends Task implements FTPTaskConfig {
throws IOException, BuildException {
String workingDirectory = ftp.printWorkingDirectory();
if (verbose) {
if (dir.indexOf("/") == 0 || workingDirectory == null) {
if (dir.startsWith("/") || workingDirectory == null) {
log("Creating directory: " + dir + " in /");
} else {
log("Creating directory: " + dir + " in " + workingDirectory);
}
}
if (dir.indexOf("/") == 0) {
if (dir.startsWith("/")) {
ftp.changeWorkingDirectory("/");
}
String subdir = "";


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

@@ -628,6 +628,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
&& pcounter != icounter
&& target.equals(array[pcounter].getName())) {
candidateFound = false;
break;
}
}
if (candidateFound) {
@@ -810,7 +811,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
*/
public String getFastRelativePath() {
String absPath = getAbsolutePath();
if (absPath.indexOf(rootPath + task.getSeparator()) == 0) {
if (absPath.startsWith(rootPath + task.getSeparator())) {
return absPath.substring(rootPath.length()
+ task.getSeparator().length());
}
@@ -1757,13 +1758,13 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
throws IOException, BuildException {
String workingDirectory = ftp.printWorkingDirectory();
if (task.isVerbose()) {
if (dir.indexOf("/") == 0 || workingDirectory == null) {
if (dir.startsWith("/") || workingDirectory == null) {
task.log("Creating directory: " + dir + " in /");
} else {
task.log("Creating directory: " + dir + " in " + workingDirectory);
}
}
if (dir.indexOf("/") == 0) {
if (dir.startsWith("/")) {
ftp.changeWorkingDirectory("/");
}
String subdir = "";


+ 1
- 1
src/main/org/apache/tools/ant/util/FileUtils.java View File

@@ -637,7 +637,7 @@ public class FileUtils {
int len = filename.length();
return (c == sep && (len == 1 || filename.charAt(1) != sep))
|| (Character.isLetter(c) && len > 1
&& filename.indexOf(':') == 1
&& filename.charAt(1) == ':'
&& (len == 2 || filename.charAt(2) != sep));
}



+ 18
- 0
src/main/org/apache/tools/ant/util/IdentityStack.java View File

@@ -17,6 +17,10 @@
*/
package org.apache.tools.ant.util;

import java.util.Collection;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Set;
import java.util.Stack;

/**
@@ -102,4 +106,18 @@ public class IdentityStack<E> extends Stack<E> {
return -1;
}

public synchronized boolean removeAll(Collection<?> c) {
if (!(c instanceof Set)) {
c = new HashSet(c);
}
return super.removeAll(c);
}

public synchronized boolean containsAll(Collection<?> c) {
IdentityHashMap map = new IdentityHashMap();
for (Object e : this) {
map.put(e, Boolean.TRUE);
}
return map.keySet().containsAll(c);
}
}

+ 1
- 1
src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java View File

@@ -410,7 +410,7 @@ public class DirectoryScannerTest extends BuildFileTest {
// ${tests.and.ant.share.classloader} will be set
// we are trying to catch this here.
if (shareclassloader == null
|| (shareclassloader != null && shareclassloader.indexOf("${") == 0)) {
|| (shareclassloader != null && shareclassloader.startsWith("${"))) {
System.out.println("cannot execute testIsExcludedDirectoryScanned when tests are forked, " +
"package private method called");
return;


+ 2
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java View File

@@ -204,7 +204,7 @@ public class XmlPropertyTest extends BuildFileTest {

String xmlValue = (String)xmlproperties.get(currentKey);

if ( propertyValue.indexOf("ID.") == 0 ) {
if (propertyValue.startsWith("ID.")) {
// The property is an id's thing -- either a property
// or a path. We need to make sure
// that the object was created with the given id.
@@ -231,7 +231,7 @@ public class XmlPropertyTest extends BuildFileTest {

} else {

if (propertyValue.indexOf("FILE.") == 0) {
if (propertyValue.startsWith("FILE.")) {
// The property is the name of a file. We are testing
// a location attribute, so we need to resolve the given
// file name in the provided folder.


Loading…
Cancel
Save