Change RDN compare funcs, we don't need lexical ordering

This commit is contained in:
Howard Chu 2003-04-23 10:26:06 +00:00
parent 4a51d2457a
commit 184f647b25
2 changed files with 10 additions and 13 deletions

View file

@ -169,13 +169,14 @@ bdb_cache_entryinfo_destroy( EntryInfo *e )
} \
} while(0)
/* Do a lexical sort on normalized RDNs */
/* Do a length-ordered sort on normalized RDNs */
static int
bdb_rdn_cmp( const void *v_e1, const void *v_e2 )
{
const EntryInfo *e1 = v_e1, *e2 = v_e2;
int rc = strncmp( e1->bei_nrdn.bv_val, e2->bei_nrdn.bv_val, e1->bei_nrdn.bv_len );
if (rc == 0) rc = e1->bei_nrdn.bv_len - e2->bei_nrdn.bv_len;
int rc = e1->bei_nrdn.bv_len - e2->bei_nrdn.bv_len;
if (rc == 0) rc = strncmp( e1->bei_nrdn.bv_val, e2->bei_nrdn.bv_val,
e1->bei_nrdn.bv_len );
return rc;
}
@ -288,8 +289,10 @@ bdb_entryinfo_add_internal(
addkid = 0;
cache->c_cursize -= incr;
#ifdef BDB_HIER
if ( ei->bei_rdn.bv_val )
if ( ei->bei_rdn.bv_val ) {
ber_memfree_x( ei->bei_rdn.bv_val, NULL );
ei->bei_rdn.bv_val = NULL;
}
#endif
} else {
LRU_ADD( cache, ei2 );

View file

@ -503,7 +503,7 @@ typedef struct diskNode {
} diskNode;
/* Sort function for the sorted duplicate data items of a dn2id key.
* Sorts based on normalized RDN, in lexical order.
* Sorts based on normalized RDN, in length order.
*/
int
bdb_dup_compare(
@ -530,15 +530,9 @@ bdb_dup_compare(
curlen = ptr[0] << 8 | *pt2;
if ( usrlen < 0 ) {
if ( curlen < 0 ) return 0;
return -1;
}
rc = usrlen - curlen;
if ( curlen < 0 ) return 1;
rc = strncmp( usr->nrdn, cur->nrdn, usrlen );
if ( rc == 0 ) rc = usrlen - curlen;
if ( rc == 0 ) rc = strncmp( usr->nrdn, cur->nrdn, usrlen );
return rc;
}