directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r521995 - /directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java
Date Sat, 24 Mar 2007 08:58:22 GMT
Author: elecharny
Date: Sat Mar 24 01:58:21 2007
New Revision: 521995

URL: http://svn.apache.org/viewvc?view=rev&rev=521995
Log:
Replaced the Arrays.hashCode( byte[] ) by a call to a private method to compute the hashCode.

Modified:
    directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java

Modified: directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java?view=diff&rev=521995&r1=521994&r2=521995
==============================================================================
--- directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java
(original)
+++ directory/shared/branches/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java
Sat Mar 24 01:58:21 2007
@@ -579,7 +579,18 @@
     	}
     }
 
-
+    private int computeArrayHashCode( byte[] bv )
+    {
+        int h = 27;
+        
+        for ( int i = 0; i < bv.length; i++ )
+        {
+            h += 37*bv[i];
+        }
+        
+        return h;
+    }
+    
     /**
      * Checks for equality between this Attribute instance and another. The
      * lockable properties are not factored into the equality semantics and
@@ -662,14 +673,15 @@
                 else if ( v instanceof byte[] )
                 {
                     byte[] bv = (byte[])v;
-                    h = Arrays.hashCode( bv );
+                    
+                    h = computeArrayHashCode( bv );
                 }
                 else
                 {
                     return false;
                 }
                 
-                hash.put( Integer.valueOf( h ), v );
+                hash.put( new Integer( h ), v );
             }
             
             try
@@ -682,7 +694,7 @@
                     
                     if ( val instanceof String )
                     {
-                        Integer h = Integer.valueOf( val.hashCode() );
+                        Integer h = new Integer( val.hashCode() );
                         
                         if ( !hash.containsKey( h ) )
                         {
@@ -700,7 +712,7 @@
                     }
                     else if ( val instanceof byte[] )
                     {
-                        Integer h = Integer.valueOf( Arrays.hashCode( (byte[])val ) );
+                        Integer h = new Integer( computeArrayHashCode( (byte[])val ) );
 
                         if ( !hash.containsKey( h ) )
                         {



Mime
View raw message