commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1300916 - in /commons/sandbox/beanutils2/trunk/src: changes/changes.xml main/java/org/apache/commons/beanutils2/AccessibleObjectsRegistry.java
Date Thu, 15 Mar 2012 11:20:10 GMT
Author: simonetripodi
Date: Thu Mar 15 11:20:10 2012
New Revision: 1300916

URL: http://svn.apache.org/viewvc?rev=1300916&view=rev
Log:
[SANDBOX-401] Performance improvement: store hash code of AccessibleObjectDescriptor as member
variable - patch provided by Benedikt Ritter

Modified:
    commons/sandbox/beanutils2/trunk/src/changes/changes.xml
    commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/AccessibleObjectsRegistry.java

Modified: commons/sandbox/beanutils2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/changes/changes.xml?rev=1300916&r1=1300915&r2=1300916&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/changes/changes.xml (original)
+++ commons/sandbox/beanutils2/trunk/src/changes/changes.xml Thu Mar 15 11:20:10 2012
@@ -23,6 +23,9 @@
   </properties>
   <body>
   <release version="0.1" date="201?-??-??" description="First release.">
+    <action dev="simonetripodi" type="add" issue="SANDBOX-401" due-to="Benedikt Ritter">
+      Performance improvement: store hash code of AccessibleObjectDescriptor as member variable
+    </action>
     <action dev="simonetripodi" type="add" issue="SANDBOX-396" due-to="Benedikt Ritter">
       Implement clone() on DefaultBeanAccessor
     </action>

Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/AccessibleObjectsRegistry.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/AccessibleObjectsRegistry.java?rev=1300916&r1=1300915&r2=1300916&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/AccessibleObjectsRegistry.java
(original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/AccessibleObjectsRegistry.java
Thu Mar 15 11:20:10 2012
@@ -28,14 +28,9 @@ import static org.apache.commons.beanuti
 
 import java.lang.ref.Reference;
 import java.lang.ref.WeakReference;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
+import java.lang.reflect.*;
 import java.security.PrivilegedAction;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.WeakHashMap;
+import java.util.*;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
@@ -501,6 +496,8 @@ abstract class AccessibleObjectsRegistry
 
         private final boolean exact;
 
+        private final int hashCode;
+
         /**
          * The sole constructor.
          *
@@ -515,11 +512,16 @@ abstract class AccessibleObjectsRegistry
             this.type = type;
             this.methodName = methodName;
             this.paramTypes = paramTypes;
+            hashCode = hashCode();
         }
 
         @Override
         public int hashCode()
         {
+            if ( hashCode != 0 )
+            {
+                return hashCode;
+            }
             final int prime = 31;
             int result = 1;
             result = prime * result + ( ( type == null ) ? 0 : type.getName().hashCode()
);



Mime
View raw message