From: Howard Chu Date: Wed, 17 Jan 2007 10:43:37 +0000 (+0000) Subject: Only sort the first time X-Git-Tag: OPENLDAP_REL_ENG_2_4_4ALPHA~8^2~175 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9a8b3f711e775d412cfcb290cc3616202c37b858;p=openldap Only sort the first time --- diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index d79bc18d6e..f22a057ec9 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -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++ ) {