ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [2/2] ant git commit: Fix the inefficient use of keySet iterator with entrySet iterator.
Date Fri, 13 Oct 2017 06:43:06 GMT
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/1.9.x
Commit: 013e9159e927cf96493a5f8577cfd2807cb045c8
Parents: c141ef4
Author: Kui LIU <brucekuiliu@gmail.com>
Authored: Wed Oct 11 14:18:19 2017 +0200
Committer: Stefan Bodewig <bodewig@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;
         }


Mime
View raw message