int rc, weight1, weight2;
switch( f1->f_choice ) {
- case LDAP_FILTER_PRESENT:
+ case LDAP_FILTER_AND:
+ case LDAP_FILTER_OR:
weight1 = 0;
break;
+ case LDAP_FILTER_PRESENT:
+ weight1 = 1;
+ break;
case LDAP_FILTER_EQUALITY:
case LDAP_FILTER_GE:
case LDAP_FILTER_LE:
- weight1 = 1;
+ weight1 = 2;
break;
default:
- weight1 = 2;
+ weight1 = 3;
}
switch( f2->f_choice ) {
- case LDAP_FILTER_PRESENT:
+ case LDAP_FILTER_AND:
+ case LDAP_FILTER_OR:
weight2 = 0;
break;
+ case LDAP_FILTER_PRESENT:
+ weight2 = 1;
+ break;
case LDAP_FILTER_EQUALITY:
case LDAP_FILTER_GE:
case LDAP_FILTER_LE:
- weight2 = 1;
+ weight2 = 2;
break;
default:
- weight2 = 2;
+ weight2 = 3;
}
rc = weight1 - weight2;
if ( !rc ) {
switch( weight1 ) {
case 0:
+ rc = pcache_filter_cmp( f1->f_and, f2->f_and );
break;
case 1:
- rc = lex_bvcmp( &f1->f_av_value, &f2->f_av_value );
break;
case 2:
+ rc = lex_bvcmp( &f1->f_av_value, &f2->f_av_value );
+ break;
+ case 3:
if ( f1->f_choice == LDAP_FILTER_SUBSTRINGS ) {
rc = 0;
if ( !BER_BVISNULL( &f1->f_sub_initial )) {
}
break;
}
- if ( !rc ) {
+ while ( !rc ) {
f1 = f1->f_next;
f2 = f2->f_next;
if ( f1 || f2 ) {
else if ( !f2 )
rc = 1;
else {
- while ( f1->f_choice == LDAP_FILTER_AND || f1->f_choice == LDAP_FILTER_OR )
- f1 = f1->f_and;
- while ( f2->f_choice == LDAP_FILTER_AND || f2->f_choice == LDAP_FILTER_OR )
- f2 = f2->f_and;
rc = pcache_filter_cmp( f1, f2 );
}
+ } else {
+ break;
}
}
}
static int pcache_query_cmp( const void *v1, const void *v2 )
{
const CachedQuery *q1 = v1, *q2 =v2;
- return pcache_filter_cmp( q1->first, q2->first );
+ return pcache_filter_cmp( q1->filter, q2->filter );
}
/* add query on top of LRU list */