Author: bodewig
Date: Thu Jan 2 14:37:32 2014
New Revision: 1554813
URL: http://svn.apache.org/r1554813
Log:
assorted micro-optimizations by Adrian Nistor - 13 different Bugzilla issues
Modified:
ant/core/trunk/CONTRIBUTORS
ant/core/trunk/contributors.xml
ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java
ant/core/trunk/src/main/org/apache/tools/ant/util/IdentityStack.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java
Modified: ant/core/trunk/CONTRIBUTORS
URL:
http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=1554813&r1=1554812&r2=1554813&view=diff
==============================================================================
--- ant/core/trunk/CONTRIBUTORS (original)
+++ ant/core/trunk/CONTRIBUTORS Thu Jan 2 14:37:32 2014
@@ -3,6 +3,7 @@ Amongst other, the following people cont
Adam Blinkinsop
Adam Bryzak
Adam Sotona
+Adrian Nistor
Aleksandr Ishutin
Alex Rosen
Alexei Yudichev
Modified: ant/core/trunk/contributors.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=1554813&r1=1554812&r2=1554813&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Thu Jan 2 14:37:32 2014
@@ -43,6 +43,10 @@
<last>Sotona</last>
</name>
<name>
+ <first>Adrian</first>
+ <last>Nistor</last>
+ </name>
+ <name>
<first>Aleksandr</first>
<last>Ishutin</last>
</name>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java?rev=1554813&r1=1554812&r2=1554813&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java Thu Jan
2 14:37:32 2014
@@ -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.");
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java?rev=1554813&r1=1554812&r2=1554813&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java
Thu Jan 2 14:37:32 2014
@@ -156,7 +156,7 @@ public class FailureRecorder extends Pro
Object listener = allListeners.get(i);
if (listener instanceof FailureRecorder) {
alreadyRegistered = true;
- continue;
+ break;
}
}
// register if needed
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java?rev=1554813&r1=1554812&r2=1554813&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
Thu Jan 2 14:37:32 2014
@@ -727,6 +727,7 @@ public class FTP extends Task implements
&& pcounter != icounter
&& target.equals(array[pcounter].getName())) {
candidateFound = false;
+ break;
}
}
if (candidateFound) {
@@ -908,7 +909,7 @@ public class FTP extends Task implements
*/
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
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 = "";
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java?rev=1554813&r1=1554812&r2=1554813&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
Thu Jan 2 14:37:32 2014
@@ -628,6 +628,7 @@ public class FTPTaskMirrorImpl implement
&& pcounter != icounter
&& target.equals(array[pcounter].getName())) {
candidateFound = false;
+ break;
}
}
if (candidateFound) {
@@ -810,7 +811,7 @@ public class FTPTaskMirrorImpl implement
*/
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 implement
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 = "";
Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java?rev=1554813&r1=1554812&r2=1554813&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java Thu Jan 2
14:37:32 2014
@@ -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));
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/IdentityStack.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/IdentityStack.java?rev=1554813&r1=1554812&r2=1554813&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/IdentityStack.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/IdentityStack.java Thu
Jan 2 14:37:32 2014
@@ -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 St
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);
+ }
}
Modified:
ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java?rev=1554813&r1=1554812&r2=1554813&view=diff
==============================================================================
---
ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
(original)
+++
ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
Thu Jan 2 14:37:32 2014
@@ -410,7 +410,7 @@ public class DirectoryScannerTest extend
// ${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;
Modified:
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java?rev=1554813&r1=1554812&r2=1554813&view=diff
==============================================================================
---
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java
(original)
+++
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java
Thu Jan 2 14:37:32 2014
@@ -204,7 +204,7 @@ public class XmlPropertyTest extends Bui
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 Bui
} 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.