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:24 UTC

[5/6] ant git commit: Fix the inefficient use of keySet iterator with entrySet iterator.

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);