directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1331784 - /directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
Date Sat, 28 Apr 2012 15:14:37 GMT
Author: elecharny
Date: Sat Apr 28 15:14:37 2012
New Revision: 1331784

URL: http://svn.apache.org/viewvc?rev=1331784&view=rev
Log:
Simplified and speeded up the RDN comparison

Modified:
    directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java?rev=1331784&r1=1331783&r2=1331784&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
(original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
Sat Apr 28 15:14:37 2012
@@ -226,6 +226,8 @@ public class ParentIdAndRdn<ID extends C
         {
             return val;
         }
+        
+        // The ID is the same, check the RDNs now
 
         val = rdns.length - that.rdns.length;
 
@@ -234,47 +236,27 @@ public class ParentIdAndRdn<ID extends C
             return val;
         }
         
-        StringBuilder sb = new StringBuilder();
-        boolean isFirst = true;
-        
-        for ( Rdn rdn : rdns )
+        if ( rdns.length == 1 )
         {
-            if ( isFirst )
-            {
-                sb.append( ',' );
-            }
-            else
-            {
-                isFirst = false;
-            }
+            // Special case : we only have one rdn.
+            val = rdns[0].getNormName().compareTo( that.rdns[0].getNormName() );
             
-            sb.append( rdn.getNormName() );
+            return val;
         }
-        
-        String thisString = sb.toString();
-        
-        isFirst = true;
-        sb = new StringBuilder();
-
-        for ( Rdn rdn : that.rdns )
+        else
         {
-            if ( isFirst )
+            for ( int i = 0; i < rdns.length; i++ )
             {
-                sb.append( ',' );
-            }
-            else
-            {
-                isFirst = false;
+                val = rdns[i].getNormName().compareTo( that.rdns[i].getNormName() );
+            
+                if ( val != 0 )
+                {
+                    return val;
+                }
             }
             
-            sb.append( rdn.getNormName() );
+            return 0;
         }
-        
-        String thatString = sb.toString();
-        
-        val = ( thisString.compareTo( thatString ) );
-        
-        return val;
     }
 
 



Mime
View raw message