Author: bodewig
Date: Wed Feb 17 10:05:08 2010
New Revision: 910889
URL: http://svn.apache.org/viewvc?rev=910889&view=rev
Log:
Change more List#contains() cases, most of the changes are unlikely to have a
real performance impact since the lists usually are too small
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/Project.java
ant/core/trunk/src/main/org/apache/tools/ant/input/InputRequest.java
ant/core/trunk/src/main/org/apache/tools/ant/input/MultipleChoiceInputRequest.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/taskdefs/optional/ssh/Directory.java
ant/core/trunk/src/main/org/apache/tools/ant/types/FilterSet.java
ant/core/trunk/src/main/org/apache/tools/ant/util/CompositeMapper.java
ant/core/trunk/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/Project.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Project.java?rev=910889&r1=910888&r2=910889&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Project.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Project.java Wed Feb 17
10:05:08 2010
@@ -48,6 +48,7 @@
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.JavaEnvUtils;
import org.apache.tools.ant.util.StringUtils;
+import org.apache.tools.ant.util.VectorSet;
/**
* Central representation of an Ant project. This class defines an
@@ -1799,7 +1800,7 @@
*/
public final Vector topoSort(String[] root, Hashtable targetTable,
boolean returnAll) throws BuildException {
- Vector ret = new Vector();
+ Vector ret = new VectorSet();
Hashtable state = new Hashtable();
Stack visiting = new Stack();
Modified: ant/core/trunk/src/main/org/apache/tools/ant/input/InputRequest.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/input/InputRequest.java?rev=910889&r1=910888&r2=910889&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/input/InputRequest.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/input/InputRequest.java Wed
Feb 17 10:05:08 2010
@@ -24,7 +24,7 @@
* @since Ant 1.5
*/
public class InputRequest {
- private String prompt;
+ private final String prompt;
private String input;
private String defaultValue;
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/input/MultipleChoiceInputRequest.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/input/MultipleChoiceInputRequest.java?rev=910889&r1=910888&r2=910889&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/input/MultipleChoiceInputRequest.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/input/MultipleChoiceInputRequest.java
Wed Feb 17 10:05:08 2010
@@ -18,6 +18,7 @@
package org.apache.tools.ant.input;
+import java.util.LinkedHashSet;
import java.util.Vector;
/**
@@ -26,7 +27,7 @@
* @since Ant 1.5
*/
public class MultipleChoiceInputRequest extends InputRequest {
- private Vector choices = new Vector();
+ private final LinkedHashSet choices;
/**
* @param prompt The prompt to show to the user. Must not be null.
@@ -38,14 +39,14 @@
if (choices == null) {
throw new IllegalArgumentException("choices must not be null");
}
- this.choices = choices;
+ this.choices = new LinkedHashSet(choices);
}
/**
* @return The possible values.
*/
public Vector getChoices() {
- return choices;
+ return new Vector(choices);
}
/**
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=910889&r1=910888&r2=910889&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
Wed Feb 17 10:05:08 2010
@@ -32,10 +32,12 @@
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
import java.util.StringTokenizer;
import java.util.Vector;
@@ -54,6 +56,7 @@
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.RetryHandler;
import org.apache.tools.ant.util.Retryable;
+import org.apache.tools.ant.util.VectorSet;
/**
* Basic FTP client. Performs the following actions:
@@ -116,7 +119,7 @@
private boolean timeDiffAuto = false;
private int action = SEND_FILES;
private Vector filesets = new Vector();
- private Vector dirCache = new Vector();
+ private Set dirCache = new HashSet();
private int transferred = 0;
private String remoteFileSep = "/";
private int port = DEFAULT_FTP_PORT;
@@ -354,12 +357,12 @@
excludes = new String[0];
}
- filesIncluded = new Vector();
+ filesIncluded = new VectorSet();
filesNotIncluded = new Vector();
- filesExcluded = new Vector();
- dirsIncluded = new Vector();
+ filesExcluded = new VectorSet();
+ dirsIncluded = new VectorSet();
dirsNotIncluded = new Vector();
- dirsExcluded = new Vector();
+ dirsExcluded = new VectorSet();
try {
String cwd = ftp.printWorkingDirectory();
@@ -1919,7 +1922,7 @@
+ "directory: " +
ftp.getReplyString());
}
}
- dirCache.addElement(dir);
+ dirCache.add(dir);
}
ftp.changeWorkingDirectory(cwd);
}
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=910889&r1=910888&r2=910889&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
Wed Feb 17 10:05:08 2010
@@ -50,6 +50,7 @@
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.RetryHandler;
import org.apache.tools.ant.util.Retryable;
+import org.apache.tools.ant.util.VectorSet;
public class FTPTaskMirrorImpl implements FTPTaskMirror {
@@ -63,7 +64,7 @@
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
private final FTPTask task;
- private Vector dirCache = new Vector();
+ private Set dirCache = new HashSet();
private int transferred = 0;
private int skipped = 0;
@@ -257,12 +258,12 @@
excludes = new String[0];
}
- filesIncluded = new Vector();
+ filesIncluded = new VectorSet();
filesNotIncluded = new Vector();
- filesExcluded = new Vector();
- dirsIncluded = new Vector();
+ filesExcluded = new VectorSet();
+ dirsIncluded = new VectorSet();
dirsNotIncluded = new Vector();
- dirsExcluded = new Vector();
+ dirsExcluded = new VectorSet();
try {
String cwd = ftp.printWorkingDirectory();
@@ -1310,7 +1311,7 @@
+ "directory: " +
ftp.getReplyString());
}
}
- dirCache.addElement(dir);
+ dirCache.add(dir);
}
ftp.changeWorkingDirectory(cwd);
}
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java?rev=910889&r1=910888&r2=910889&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java
Wed Feb 17 10:05:08 2010
@@ -20,6 +20,8 @@
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
import java.util.StringTokenizer;
import java.io.File;
@@ -29,7 +31,7 @@
public class Directory {
private File directory;
- private ArrayList childDirectories;
+ private Set childDirectories;
private ArrayList files;
private Directory parent;
@@ -48,7 +50,7 @@
*/
public Directory(File directory , Directory parent) {
this.parent = parent;
- this.childDirectories = new ArrayList();
+ this.childDirectories = new LinkedHashSet();
this.files = new ArrayList();
this.directory = directory;
}
@@ -117,8 +119,8 @@
* @return the child directory, or null if not found
*/
public Directory getChild(File dir) {
- for (int i = 0; i < childDirectories.size(); i++) {
- Directory current = (Directory) childDirectories.get(i);
+ for (Iterator i = childDirectories.iterator(); i.hasNext(); ) {
+ Directory current = (Directory) i.next();
if (current.getDirectory().equals(dir)) {
return current;
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/FilterSet.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/FilterSet.java?rev=910889&r1=910888&r2=910889&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/FilterSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/FilterSet.java Wed Feb
17 10:05:08 2010
@@ -27,6 +27,7 @@
import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.util.VectorSet;
/**
* A set of filters to be applied to something.
@@ -575,7 +576,7 @@
String beginToken = getBeginToken();
String endToken = getEndToken();
if (recurseDepth == 0) {
- passedTokens = new Vector();
+ passedTokens = new VectorSet();
}
recurseDepth++;
if (passedTokens.contains(parent) && !duplicateToken) {
Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/CompositeMapper.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/CompositeMapper.java?rev=910889&r1=910888&r2=910889&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/CompositeMapper.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/CompositeMapper.java Wed
Feb 17 10:05:08 2010
@@ -17,10 +17,8 @@
*/
package org.apache.tools.ant.util;
-import java.util.Arrays;
-import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedList;
+import java.util.LinkedHashSet;
/**
* A <CODE>ContainerMapper</CODE> that unites the results of its constituent
@@ -30,8 +28,7 @@
/** {...@inheritdoc}. */
public String[] mapFileName(String sourceFileName) {
- HashSet results = new HashSet();
- LinkedList sortedResults = new LinkedList();
+ LinkedHashSet results = new LinkedHashSet();
FileNameMapper mapper = null;
for (Iterator mIter = getMappers().iterator(); mIter.hasNext();) {
@@ -40,16 +37,13 @@
String[] mapped = mapper.mapFileName(sourceFileName);
if (mapped != null) {
for (int i = 0; i < mapped.length; i++) {
- if (!results.contains(mapped[i])) {
- results.add(mapped[i]);
- sortedResults.addLast(mapped[i]);
- }
+ results.add(mapped[i]);
}
}
}
}
return (results.size() == 0) ? null
- : (String[]) sortedResults.toArray(new String[results.size()]);
+ : (String[]) results.toArray(new String[results.size()]);
}
}
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java?rev=910889&r1=910888&r2=910889&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/util/depend/AbstractAnalyzer.java
Wed Feb 17 10:05:08 2010
@@ -22,6 +22,7 @@
import java.util.Vector;
import java.util.zip.ZipFile;
import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.util.VectorSet;
/**
* An abstract implementation of the analyzer interface providing support
@@ -39,7 +40,7 @@
private Path classPath = new Path(null);
/** The list of root classes */
- private Vector rootClasses = new Vector();
+ private final Vector rootClasses = new VectorSet();
/** true if dependencies have been determined */
private boolean determined = false;