Browse Source

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.
master
Kui LIU Stefan Bodewig 7 years ago
parent
commit
013e9159e9
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      src/main/org/apache/tools/ant/filters/ReplaceTokens.java

+ 3
- 2
src/main/org/apache/tools/ant/filters/ReplaceTokens.java View File

@@ -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;
}


Loading…
Cancel
Save