db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1085409 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/load/ColumnInfo.java tools/org/apache/derby/impl/tools/dblook/DB_Table.java
Date Fri, 25 Mar 2011 14:40:10 GMT
Author: kahatlen
Date: Fri Mar 25 14:40:10 2011
New Revision: 1085409

URL: http://svn.apache.org/viewvc?rev=1085409&view=rev
Log:
DERBY-5021: avoid map look ups in a loop by using entrySet

Patch contributed by Dave Brosius <dbrosius@apache.org>.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Table.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java?rev=1085409&r1=1085408&r2=1085409&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java Fri Mar 25
14:40:10 2011
@@ -555,12 +555,13 @@ class ColumnInfo {
         if ( stringMap == null ) { return null; }
         
         HashMap retval = new HashMap();
-        Iterator keys = stringMap.keySet().iterator();
+        Iterator entries = stringMap.entrySet().iterator();
 
-        while ( keys.hasNext() )
+        while ( entries.hasNext() )
         {
-            String columnName = (String) keys.next();
-            String className = (String) stringMap.get( columnName );
+            Map.Entry entry = (Map.Entry)entries.next();
+            String columnName = (String) entry.getKey();
+            String className = (String) entry.getValue();
 
             Class classValue = Class.forName( className );
 

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Table.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Table.java?rev=1085409&r1=1085408&r2=1085409&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Table.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Table.java Fri Mar
25 14:40:10 2011
@@ -29,6 +29,7 @@ import java.sql.SQLException;
 import java.sql.ResultSetMetaData;
 
 import java.util.HashMap;
+import java.util.Map;
 import java.util.Set;
 import java.util.Iterator;
 
@@ -76,11 +77,12 @@ public class DB_Table {
 		// each one.
 
 		boolean firstTime = true;
-		Set tableIds = tableIdToNameMap.keySet();
-		for (Iterator itr = tableIds.iterator(); itr.hasNext(); ) {
+		Set entries = tableIdToNameMap.entrySet();
+		for (Iterator itr = entries.iterator(); itr.hasNext(); ) {
 
-			String tableId = (String)itr.next();
-			String tableName = (String)(tableIdToNameMap.get(tableId));
+            Map.Entry entry = (Map.Entry)itr.next();
+			String tableId = (String)entry.getKey();
+			String tableName = (String)entry.getValue();
 			if (dblook.isExcludedTable(tableName))
 			// table isn't included in user-given list; skip it.
 				continue;



Mime
View raw message