directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r942556 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparator.java
Date Sun, 09 May 2010 16:44:47 GMT
Author: elecharny
Date: Sun May  9 16:44:47 2010
New Revision: 942556

URL: http://svn.apache.org/viewvc?rev=942556&view=rev
Log:
Speeded up the comparator by using a String comparison instead of creating two CSN.

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparator.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparator.java?rev=942556&r1=942555&r2=942556&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/CsnComparator.java
Sun May  9 16:44:47 2010
@@ -20,7 +20,6 @@
 package org.apache.directory.shared.ldap.schema.comparators;
 
 
-import org.apache.directory.shared.ldap.csn.Csn;
 import org.apache.directory.shared.ldap.entry.StringValue;
 import org.apache.directory.shared.ldap.schema.LdapComparator;
 import org.slf4j.Logger;
@@ -63,6 +62,11 @@ public class CsnComparator extends LdapC
     public int compare( Object csnObj1, Object csnObj2 )
     {
         LOG.debug( "comparing CSN objects '{}' with '{}'", csnObj1, csnObj2 );
+        
+        if ( csnObj1 == csnObj2 )
+        {
+            return 0;
+        }
 
         // -------------------------------------------------------------------
         // Handle some basis cases
@@ -80,7 +84,7 @@ public class CsnComparator extends LdapC
         String csnStr1 = null;
         String csnStr2 = null;
         
-        if( csnObj1 instanceof StringValue )
+        if ( csnObj1 instanceof StringValue )
         {
             csnStr1 = ( ( StringValue ) csnObj1 ).get();
         }
@@ -89,7 +93,7 @@ public class CsnComparator extends LdapC
             csnStr1 = csnObj1.toString();
         }
 
-        if( csnObj2 instanceof StringValue )
+        if ( csnObj2 instanceof StringValue )
         {
             csnStr2 = ( ( StringValue ) csnObj2 ).get();
         }
@@ -98,9 +102,6 @@ public class CsnComparator extends LdapC
             csnStr2 = csnObj2.toString();
         }
         
-        Csn csn1 = new Csn( csnStr1 );
-        Csn csn2 = new Csn( csnStr2 );
-        
-        return csn1.compareTo( csn2 );
+        return csnStr1.compareTo( csnStr2 );
     }
 }



Mime
View raw message