changeset 28:68163c3ca407

Directly iterate over the entry set of the map. http-client/trunk@2536 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 23 Aug 2011 13:59:20 +0000
parents 73b211b559e2
children 863c7301b7f5 7687e5cee1c3
files ChangeLog src/main/java/de/intevation/artifacts/httpclient/utils/ArtifactProtocolUtils.java
diffstat 2 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Aug 23 13:49:16 2011 +0000
+++ b/ChangeLog	Tue Aug 23 13:59:20 2011 +0000
@@ -1,3 +1,9 @@
+2011-08-23  Sascha L. Teichmann  <sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/artifacts/httpclient/utils/ArtifactProtocolUtils.java
+	  (createFeedDocument): Directly iterate over the entry set of the map. Do not
+	  use the more expensive 'for all key in keys: value = get(key)'
+	  
 2011-08-23  Sascha L. Teichmann  <sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/artifacts/httpclient/utils/ArtifactProtocolUtils.java:
--- a/src/main/java/de/intevation/artifacts/httpclient/utils/ArtifactProtocolUtils.java	Tue Aug 23 13:49:16 2011 +0000
+++ b/src/main/java/de/intevation/artifacts/httpclient/utils/ArtifactProtocolUtils.java	Tue Aug 23 13:59:20 2011 +0000
@@ -7,9 +7,7 @@
  */
 package de.intevation.artifacts.httpclient.utils;
 
-import java.util.Iterator;
 import java.util.Map;
-import java.util.Set;
 
 import javax.xml.xpath.XPathConstants;
 
@@ -43,7 +41,7 @@
 
         String uri = ArtifactNamespaceContext.NAMESPACE_URI;
 
-        for (int idx = 0, N = elements.getLength(); idx < N; idx++) {
+        for (int idx = 0; idx < facs.length; idx++) {
             Element factory = (Element)elements.item(idx);
             String desc  = factory.getAttributeNS(uri, "description");
             String name  = factory.getAttributeNS(uri, "name");
@@ -140,11 +138,11 @@
         Element action = createArtifactAction(creator, artifact, "feed");
         Element data   = creator.create("data");
 
-        Set keys      = attr.keySet();
-        Iterator iter = keys.iterator();
-        while (iter.hasNext()) {
-            String key    = (String) iter.next();
-            Object values = attr.get(key);
+        for (Map.Entry<String, Object> entry:
+            ((Map<String, Object>)attr).entrySet()) {
+
+            String key    = entry.getKey();
+            Object values = entry.getValue();
 
             if (values instanceof Object[]) {
                 appendInputNodes(creator, data, key, (Object[]) values);
@@ -152,7 +150,6 @@
             else {
                 appendInputNodes(creator, data, key, values);
             }
-
         }
 
         action.appendChild(data);

http://dive4elements.wald.intevation.org