Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CB995200D2A for ; Fri, 13 Oct 2017 08:43:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C9FCE1609E9; Fri, 13 Oct 2017 06:43:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1F6451609D1 for ; Fri, 13 Oct 2017 08:43:06 +0200 (CEST) Received: (qmail 96215 invoked by uid 500); 13 Oct 2017 06:43:06 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 96205 invoked by uid 99); 13 Oct 2017 06:43:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Oct 2017 06:43:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 79F22DFB3D; Fri, 13 Oct 2017 06:43:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bodewig@apache.org To: notifications@ant.apache.org Date: Fri, 13 Oct 2017 06:43:06 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/2] ant git commit: Fix the inefficient use of keySet iterator with entrySet iterator. archived-at: Fri, 13 Oct 2017 06:43:08 -0000 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 Authored: Wed Oct 11 14:18:19 2017 +0200 Committer: Stefan Bodewig 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 entry : hash.entrySet()) { + resolvedTokens.put(beginToken + entry.getKey() + endToken, entry.getValue()); } resolvedTokensBuilt = true; }