]> git.sur5r.net Git - openldap/commitdiff
Only sort the first time
authorHoward Chu <hyc@openldap.org>
Wed, 17 Jan 2007 10:43:37 +0000 (10:43 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 17 Jan 2007 10:43:37 +0000 (10:43 +0000)
servers/slapd/back-bdb/tools.c

index d79bc18d6e562f843d1a492b0f392aa0c206a0f9..f22a057ec9ade75e921edaf8c59f927186575015 100644 (file)
@@ -604,17 +604,19 @@ int bdb_tool_entry_reindex(
        if ( adv ) {
                int i, j, n;
 
-               /* count */
-               for ( n = 0; adv[n]; n++ ) ;
-
-               /* insertion sort */
-               for ( i = 0; i < n; i++ ) {
-                       AttributeDescription *ad = adv[i];
-                       for ( j = i-1; j>=0; j--) {
-                               if ( SLAP_PTRCMP( adv[j], ad ) <= 0 ) break;
-                               adv[j+1] = adv[j];
+               if ( bi->bi_attrs[0]->ai_desc != adv[0] ) {
+                       /* count */
+                       for ( n = 0; adv[n]; n++ ) ;
+
+                       /* insertion sort */
+                       for ( i = 0; i < n; i++ ) {
+                               AttributeDescription *ad = adv[i];
+                               for ( j = i-1; j>=0; j--) {
+                                       if ( SLAP_PTRCMP( adv[j], ad ) <= 0 ) break;
+                                       adv[j+1] = adv[j];
+                               }
+                               adv[j+1] = ad;
                        }
-                       adv[j+1] = ad;
                }
 
                for ( i = 0; adv[i]; i++ ) {