From 2ebb8363effaa205972ba7f056aa6435a7fa8d62 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Wed, 4 Sep 2013 15:55:40 -0700 Subject: gluegen: loop over entries in HashMap directly rather than looping over keys This saves repeated lookups of the value mapped to each key by just looping over the entries directly. Also remove the URIException clause as this method never can throw that exception. Signed-off-by: Harvey Harrison --- src/java/com/jogamp/common/net/URIQueryProps.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/java/com/jogamp/common/net/URIQueryProps.java b/src/java/com/jogamp/common/net/URIQueryProps.java index 543fb10..fd91b9b 100644 --- a/src/java/com/jogamp/common/net/URIQueryProps.java +++ b/src/java/com/jogamp/common/net/URIQueryProps.java @@ -32,6 +32,7 @@ import java.net.URISyntaxException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; /** * Helper class to process URI's query, handled as properties. @@ -59,7 +60,7 @@ public class URIQueryProps { public final Map getProperties() { return properties; } public final char getQuerySeparator() { return query_separator.charAt(0); } - public final String appendQuery(String baseQuery) throws URISyntaxException { + public final String appendQuery(String baseQuery) { boolean needsSep = false; final StringBuilder sb = new StringBuilder(); if ( null != baseQuery ) { @@ -71,16 +72,15 @@ public class URIQueryProps { needsSep = true; } } - Iterator propKeys = properties.keySet().iterator(); - while(propKeys.hasNext()) { + Iterator> entries = properties.entrySet().iterator(); + while(entries.hasNext()) { if(needsSep) { sb.append(query_separator); } - final String key = propKeys.next(); - final String val = properties.get(key); - sb.append(key); - if( EMPTY != val ) { - sb.append(ASSIG).append(properties.get(key)); + final Entry entry = entries.next(); + sb.append(entry.getKey()); + if( EMPTY != entry.getValue() ) { + sb.append(ASSIG).append(entry.getValue()); } needsSep = true; } -- cgit v1.2.3