Author: simonetripodi
Date: Thu Mar 15 11:26:25 2012
New Revision: 1300925
URL: http://svn.apache.org/viewvc?rev=1300925&view=rev
Log:
just incrementally built the hashcode in the constructor
Modified:
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/AccessibleObjectsRegistry.java
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=1300925&r1=1300924&r2=1300925&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:26:25 2012
@@ -508,27 +508,28 @@ abstract class AccessibleObjectsRegistry
*/
public AccessibleObjectDescriptor( boolean exact, Class<?> type,
String methodName, Class<?>... paramTypes )
{
+ final int prime = 31;
+ int hashCode = 1;
+
this.exact = exact;
+ hashCode = prime * hashCode + ( exact ? 1231 : 1237 );
+
this.type = type;
+ hashCode = prime * hashCode + ( ( type == null ) ? 0 :
type.getName().hashCode() );
+
this.methodName = methodName;
+ hashCode = prime * hashCode + ( ( methodName == null ) ? 0 :
methodName.hashCode() );
+
this.paramTypes = paramTypes;
- hashCode = hashCode();
+ hashCode = prime * hashCode + Arrays.hashCode( paramTypes );
+
+ this.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() );
- result = prime * result + ( exact ? 1231 : 1237 );
- result = prime * result + ( ( methodName == null ) ? 0 :
methodName.hashCode() );
- result = prime * result + Arrays.hashCode( paramTypes );
- return result;
+ return hashCode;
}
@Override