]> git.sur5r.net Git - openldap/commitdiff
Fix redundant index lookups from component matching
authorHoward Chu <hyc@openldap.org>
Mon, 24 Jan 2005 12:25:37 +0000 (12:25 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 24 Jan 2005 12:25:37 +0000 (12:25 +0000)
servers/slapd/back-bdb/attr.c
servers/slapd/back-bdb/index.c
servers/slapd/back-bdb/proto-bdb.h

index 73c35c86c2078cce61b68f50d253d1dd1aac6828..70a20ea9c1caecd877e21117168e1c24327e725f 100644 (file)
@@ -67,6 +67,24 @@ bdb_attr_comp_ref(
        
        *cr = a != NULL ? a->ai_cr : 0 ;
 }
+void
+bdb_attr_mask_cr(
+       struct bdb_info *bdb,
+       AttributeDescription *desc,
+       slap_mask_t *indexmask,
+       ComponentReference** cr )
+{
+       AttrInfo        *a;
+
+       a = (AttrInfo *) avl_find( bdb->bi_attrs, desc, ainfo_type_cmp );
+       if ( a ) {
+               *indexmask = a->ai_indexmask;
+               *cr = a->ai_cr;
+       } else {
+               *indexmask = NULL;
+               *cr = NULL;
+       }
+}
 #endif
 
 void
index 6f101275be1381fe06946781603b3d11727facc2..3e725c880039a8103b325c824bda75489828842d 100644 (file)
@@ -283,20 +283,21 @@ static int index_at_values(
                if( rc ) return rc;
        }
 
-#ifdef LDAP_COMP_MATCH
-       /* component indexing */
-       bdb_attr_comp_ref ( op->o_bd->be_private, type->sat_ad, &cr_list );
-       if ( cr_list ) {
-               for( cr = cr_list ; cr ; cr = cr->cr_next ) {
-                       rc = indexer( op, txn, cr->cr_ad, &type->sat_cname,
-                               cr->cr_nvals, id, opid,
-                               cr->cr_indexmask );
-               }
-       }
-#endif
        /* If this type has no AD, we've never used it before */
        if( type->sat_ad ) {
+#ifdef LDAP_COMP_MATCH
+               /* component indexing */
+               bdb_attr_mask_cr( op->o_bd->be_private, type->sat_ad, &mask, &cr_list );
+               if ( cr_list ) {
+                       for( cr = cr_list ; cr ; cr = cr->cr_next ) {
+                               rc = indexer( op, txn, cr->cr_ad, &type->sat_cname,
+                                       cr->cr_nvals, id, opid,
+                                       cr->cr_indexmask );
+                       }
+               }
+#else
                bdb_attr_mask( op->o_bd->be_private, type->sat_ad, &mask );
+#endif
                ad = type->sat_ad;
        }
 
index c770b3fc4221d811c1cacc3f8ea8541fce4b7923..48f41659d1cdf44245180bdb56b6434b3fb229a2 100644 (file)
@@ -36,9 +36,14 @@ LDAP_BEGIN_DECL
 
 #ifdef LDAP_COMP_MATCH
 #define bdb_attr_comp_ref                      BDB_SYMBOL(attr_comp_ref)
+#define bdb_attr_mask_cr                       BDB_SYMBOL(attr_mask_cr)
 void bdb_attr_comp_ref( struct bdb_info *bdb,
        AttributeDescription *desc,
        ComponentReference **cr );
+void bdb_attr_mask_cr( struct bdb_info *bdb,
+       AttributeDescription *desc,
+       slap_mask_t *indexmask,
+       ComponentReference **cr );
 #endif
 
 void bdb_attr_mask( struct bdb_info *bdb,