directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r663993 - /directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java
Date Fri, 06 Jun 2008 15:58:48 GMT
Author: elecharny
Date: Fri Jun  6 08:58:48 2008
New Revision: 663993

URL: http://svn.apache.org/viewvc?rev=663993&view=rev
Log:
Added a static hash value which is computed only once as the OID is not dynamic. This will
spare some CPU.

Modified:
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java?rev=663993&r1=663992&r2=663993&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java
Fri Jun  6 08:58:48 2008
@@ -33,6 +33,9 @@
 {
     /** a numeric object identifier */
     protected final String oid;
+    
+    /** The object hash code compiled only once to avoid doing it at every call */
+    private int hash;
 
     /** whether or not this SchemaObject is active */
     protected boolean isObsolete;
@@ -63,6 +66,8 @@
     protected AbstractSchemaObject( String oid )
     {
         this( oid, ArrayUtils.EMPTY_STRING_ARRAY, false, null );
+        
+        hash = oid.hashCode();
     }
 
 
@@ -76,6 +81,8 @@
     protected AbstractSchemaObject( String oid, String[] names )
     {
         this( oid, names, false, null );
+
+        hash = oid.hashCode();
     }
 
 
@@ -90,6 +97,8 @@
     protected AbstractSchemaObject( String oid, String[] names, boolean isObsolete )
     {
         this( oid, names, isObsolete, null );
+
+        hash = oid.hashCode();
     }
 
 
@@ -105,6 +114,8 @@
     {
         this( oid, new String[]
             { name }, isObsolete, null );
+
+        hash = oid.hashCode();
     }
 
 
@@ -118,6 +129,8 @@
     protected AbstractSchemaObject( String oid, boolean isObsolete )
     {
         this( oid, null, isObsolete, null );
+
+        hash = oid.hashCode();
     }
 
 
@@ -131,6 +144,8 @@
     protected AbstractSchemaObject( String oid, String description )
     {
         this( oid, null, false, description );
+
+        hash = oid.hashCode();
     }
 
 
@@ -158,6 +173,8 @@
         {
             this.names = names;
         }
+
+        hash = oid.hashCode();
     }
 
 
@@ -277,13 +294,14 @@
 
 
     /**
-     * Based on the hashCode of the oid property.
+     * Based on the hashCode of the oid property. It's bre-computed, as this
+     * value won't change once the instance is created.
      * 
      * @return the hashCode of the oid String
      */
     public int hashCode()
     {
-        return oid.hashCode();
+        return hash;
     }
 
 



Mime
View raw message