You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2017/10/13 06:49:20 UTC
[1/6] ant git commit: Fix the problem of using '+=' operator to
concatenate strings a in a loop.
Repository: ant
Updated Branches:
refs/heads/master a8c086cdf -> 61811c2bc
Fix the problem of using '+=' operator to concatenate strings a in a loop.
The method is building a String using concatenation in a loop.
In each iteration, the String is converted to a StringBuilder, appended to, and converted back to a String.
This can lead to a cost quadratic in the number of iterations, as the growing string is recopied in each iteration.
Better performance can be obtained by using a StringBuilder explicitly.
http://findbugs.sourceforge.net/bugDescriptions.html#SBSC_USE_STRINGBUFFER_CONCATENATION
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/c141ef40
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/c141ef40
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/c141ef40
Branch: refs/heads/master
Commit: c141ef400975be45469a0f7e4fcb2d9c5d9e6a1b
Parents: f8b5fda
Author: Kui LIU <br...@gmail.com>
Authored: Wed Oct 11 15:01:48 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Fri Oct 13 08:32:09 2017 +0200
----------------------------------------------------------------------
src/main/org/apache/tools/ant/Main.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/c141ef40/src/main/org/apache/tools/ant/Main.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java
index b104fd3..a7d4776 100644
--- a/src/main/org/apache/tools/ant/Main.java
+++ b/src/main/org/apache/tools/ant/Main.java
@@ -1292,9 +1292,9 @@ public class Main implements AntMain {
// now, start printing the targets and their descriptions
final String lSep = System.getProperty("line.separator");
// got a bit annoyed that I couldn't find a pad function
- String spaces = " ";
+ StringBuilder spaces = new StringBuilder(" ");
while (spaces.length() <= maxlen) {
- spaces += spaces;
+ spaces.append(spaces);
}
final StringBuilder msg = new StringBuilder();
msg.append(heading).append(lSep).append(lSep);
[6/6] ant git commit: make code actually compile
Posted by bo...@apache.org.
make code actually compile
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/61811c2b
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/61811c2b
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/61811c2b
Branch: refs/heads/master
Commit: 61811c2bc4ca2788b6bbb662dbc34a159d23497f
Parents: a4aec92
Author: Stefan Bodewig <bo...@apache.org>
Authored: Fri Oct 13 08:48:57 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Fri Oct 13 08:48:57 2017 +0200
----------------------------------------------------------------------
src/main/org/apache/tools/ant/taskdefs/Move.java | 5 +++--
.../tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java | 1 +
2 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/61811c2b/src/main/org/apache/tools/ant/taskdefs/Move.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Move.java b/src/main/org/apache/tools/ant/taskdefs/Move.java
index 37ef1c7..d43befd 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Move.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Move.java
@@ -19,6 +19,7 @@ package org.apache.tools.ant.taskdefs;
import java.io.File;
import java.io.IOException;
+import java.util.Map;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
@@ -134,7 +135,7 @@ public class Move extends Copy {
log("Moving " + moveCount + " file" + ((moveCount == 1) ? "" : "s")
+ " to " + destDir.getAbsolutePath());
- for (Map.Entry<String, String[]> entry : fileCopyMap.entrySet) {
+ for (Map.Entry<String, String[]> entry : fileCopyMap.entrySet()) {
String fromFile = entry.getKey();
File f = new File(fromFile);
boolean selfMove = false;
@@ -166,7 +167,7 @@ public class Move extends Copy {
if (includeEmpty) {
int createCount = 0;
- for (Map<String, String[]> entry : dirCopyMap.entrySet()) {
+ for (Map.Entry<String, String[]> entry : dirCopyMap.entrySet()) {
String fromDirName = entry.getKey();
String[] toDirNames = entry.getValue();;
boolean selfMove = false;
http://git-wip-us.apache.org/repos/asf/ant/blob/61811c2b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
index 7324bdc..d25e3c3 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
@@ -24,6 +24,7 @@ import java.nio.file.Files;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
+import java.util.Map;
import java.util.Set;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
[5/6] ant git commit: Fix the inefficient use of keySet iterator with
entrySet iterator.
Posted by bo...@apache.org.
Fix the inefficient use of keySet iterator with entrySet iterator.
The current source code accesses the key and value of a Hashtable entry, using a key that is retrieved from a keySet iterator.
It is more efficient to use an iterator on the entrySet of the Hashtable, to avoid the Map.get(key) lookup.
http://findbugs.sourceforge.net/bugDescriptions.html#WMI_WRONG_MAP_ITERATOR
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/a4aec926
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/a4aec926
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/a4aec926
Branch: refs/heads/master
Commit: a4aec926848711eb9ed04b48e28c3102b6d4ce44
Parents: 3e101e2
Author: Kui LIU <br...@gmail.com>
Authored: Wed Oct 11 14:51:12 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Fri Oct 13 08:46:04 2017 +0200
----------------------------------------------------------------------
.../tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/a4aec926/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
index 16bde5d..7324bdc 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
@@ -760,11 +760,12 @@ public class GenericDeploymentTool implements EJBDeploymentTool {
jarStream.setMethod(JarOutputStream.DEFLATED);
// Loop through all the class files found and add them to the jar
- for (String entryName : files.keySet()) {
+ for (Map.Entry<String, File> entryFiles : files.entrySet()) {
+ String entryName = entryFiles.getKey();
if (entryName.equals(MANIFEST)) {
continue;
}
- File entryFile = files.get(entryName);
+ File entryFile = entryFiles.getValue();
log("adding file '" + entryName + "'", Project.MSG_VERBOSE);
addFileToJar(jarStream, entryFile, entryName);
[3/6] ant git commit: Merge branch '1.9.x'
Posted by bo...@apache.org.
Merge branch '1.9.x'
closes #42 closes #43
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/b2b058dc
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/b2b058dc
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/b2b058dc
Branch: refs/heads/master
Commit: b2b058dcf77bae02d8f0c6140b4c411275f2aa06
Parents: a8c086c 013e915
Author: Stefan Bodewig <bo...@apache.org>
Authored: Fri Oct 13 08:43:12 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Fri Oct 13 08:43:16 2017 +0200
----------------------------------------------------------------------
src/main/org/apache/tools/ant/Main.java | 4 ++--
src/main/org/apache/tools/ant/filters/ReplaceTokens.java | 5 +++--
2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/b2b058dc/src/main/org/apache/tools/ant/Main.java
----------------------------------------------------------------------
[2/6] ant git commit: Fix the inefficient use of keySet iterator with
entrySet iterator.
Posted by bo...@apache.org.
Fix the inefficient use of keySet iterator with entrySet iterator.
The current source code accesses the key and value of a Hashtable entry, using a key that is retrieved from a keySet iterator.
It is more efficient to use an iterator on the entrySet of the Hashtable, to avoid the Map.get(key) lookup.
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/013e9159
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/013e9159
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/013e9159
Branch: refs/heads/master
Commit: 013e9159e927cf96493a5f8577cfd2807cb045c8
Parents: c141ef4
Author: Kui LIU <br...@gmail.com>
Authored: Wed Oct 11 14:18:19 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Fri Oct 13 08:42:41 2017 +0200
----------------------------------------------------------------------
src/main/org/apache/tools/ant/filters/ReplaceTokens.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/013e9159/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/filters/ReplaceTokens.java b/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
index 74da64a..bcbc312 100644
--- a/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
+++ b/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
@@ -23,6 +23,7 @@ import java.io.InputStream;
import java.io.Reader;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Map;
import java.util.Properties;
import java.util.SortedMap;
import java.util.TreeMap;
@@ -116,8 +117,8 @@ public final class ReplaceTokens
if (!resolvedTokensBuilt) {
// build the resolved tokens tree map.
- for (String key : hash.keySet()) {
- resolvedTokens.put(beginToken + key + endToken, hash.get(key));
+ for (Map.Entry<String, String> entry : hash.entrySet()) {
+ resolvedTokens.put(beginToken + entry.getKey() + endToken, entry.getValue());
}
resolvedTokensBuilt = true;
}
[4/6] ant git commit: Fix the inefficient use of keySet iterator with
entrySet iterator.
Posted by bo...@apache.org.
Fix the inefficient use of keySet iterator with entrySet iterator.
The current source code accesses the key and value of a Hashtable entry, using a key that is retrieved from a keySet iterator.
It is more efficient to use an iterator on the entrySet of the Hashtable, to avoid the Map.get(key) lookup.
http://findbugs.sourceforge.net/bugDescriptions.html#WMI_WRONG_MAP_ITERATOR
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/3e101e28
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/3e101e28
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/3e101e28
Branch: refs/heads/master
Commit: 3e101e28a9f0e3a7b08a79fcf979f8d12e3bdbb5
Parents: b2b058d
Author: Kui LIU <br...@gmail.com>
Authored: Wed Oct 11 14:42:46 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Fri Oct 13 08:45:54 2017 +0200
----------------------------------------------------------------------
src/main/org/apache/tools/ant/taskdefs/Move.java | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/3e101e28/src/main/org/apache/tools/ant/taskdefs/Move.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Move.java b/src/main/org/apache/tools/ant/taskdefs/Move.java
index 47d40e0..37ef1c7 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Move.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Move.java
@@ -105,8 +105,9 @@ public class Move extends Copy {
protected void doFileOperations() {
//Attempt complete directory renames, if any, first.
if (completeDirMap.size() > 0) {
- for (File fromDir : completeDirMap.keySet()) {
- File toDir = completeDirMap.get(fromDir);
+ for (Map.Entry<File, File> entry : completeDirMap.entrySet()) {
+ File fromDir = entry.getKey();
+ File toDir = entry.getValue();
boolean renamed = false;
try {
log("Attempting to rename dir: " + fromDir + " to " + toDir, verbosity);
@@ -133,11 +134,12 @@ public class Move extends Copy {
log("Moving " + moveCount + " file" + ((moveCount == 1) ? "" : "s")
+ " to " + destDir.getAbsolutePath());
- for (String fromFile : fileCopyMap.keySet()) {
+ for (Map.Entry<String, String[]> entry : fileCopyMap.entrySet) {
+ String fromFile = entry.getKey();
File f = new File(fromFile);
boolean selfMove = false;
if (f.exists()) { //Is this file still available to be moved?
- String[] toFiles = fileCopyMap.get(fromFile);
+ String[] toFiles = entry.getValue();
for (int i = 0; i < toFiles.length; i++) {
String toFile = toFiles[i];
@@ -164,8 +166,9 @@ public class Move extends Copy {
if (includeEmpty) {
int createCount = 0;
- for (String fromDirName : dirCopyMap.keySet()) {
- String[] toDirNames = dirCopyMap.get(fromDirName);
+ for (Map<String, String[]> entry : dirCopyMap.entrySet()) {
+ String fromDirName = entry.getKey();
+ String[] toDirNames = entry.getValue();;
boolean selfMove = false;
for (int i = 0; i < toDirNames.length; i++) {
if (fromDirName.equals(toDirNames[i])) {