You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2012/02/05 22:57:31 UTC

svn commit: r1240843 - /commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanAccessor.java

Author: simonetripodi
Date: Sun Feb  5 21:57:30 2012
New Revision: 1240843

URL: http://svn.apache.org/viewvc?rev=1240843&view=rev
Log:
iterate over Map.Entry to hit less the input Map

Modified:
    commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanAccessor.java

Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanAccessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanAccessor.java?rev=1240843&r1=1240842&r2=1240843&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanAccessor.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanAccessor.java Sun Feb  5 21:57:30 2012
@@ -27,6 +27,7 @@ import java.beans.PropertyDescriptor;
 import java.lang.reflect.InvocationTargetException;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Map.Entry;
 
 final class DefaultBeanAccessor<B>
     implements BeanAccessor<B>
@@ -167,17 +168,19 @@ final class DefaultBeanAccessor<B>
     public Map<String, Object> describe()
         throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException
     {
-        Map<String, PropertyDescriptor> propertiesIndex = registry.getPropertiesIndex( bean.getClass() );
-        Map<String, Object> result = new HashMap<String, Object>( propertiesIndex.size() );
-        for ( String key : propertiesIndex.keySet() )
+        final Map<String, PropertyDescriptor> propertiesIndex = registry.getPropertiesIndex( bean.getClass() );
+        final Map<String, Object> result = new HashMap<String, Object>( propertiesIndex.size() );
+
+        for ( Entry<String, PropertyDescriptor> key : propertiesIndex.entrySet() )
         {
-            PropertyDescriptor propertyDescriptor = propertiesIndex.get( key );
+            PropertyDescriptor propertyDescriptor = key.getValue();
             if ( propertyDescriptor.getReadMethod() != null )
             {
                 Object value = propertyDescriptor.getReadMethod().invoke( bean );
-                result.put( key, value );
+                result.put( key.getKey(), value );
             }
         }
+
         return result;
     }