From fc337704c5d27356e41166203bdd0f135cfafb8f Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 24 Jan 2005 12:25:37 +0000 Subject: [PATCH] Fix redundant index lookups from component matching --- servers/slapd/back-bdb/attr.c | 18 ++++++++++++++++++ servers/slapd/back-bdb/index.c | 23 ++++++++++++----------- servers/slapd/back-bdb/proto-bdb.h | 5 +++++ 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/servers/slapd/back-bdb/attr.c b/servers/slapd/back-bdb/attr.c index 73c35c86c2..70a20ea9c1 100644 --- a/servers/slapd/back-bdb/attr.c +++ b/servers/slapd/back-bdb/attr.c @@ -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 diff --git a/servers/slapd/back-bdb/index.c b/servers/slapd/back-bdb/index.c index 6f101275be..3e725c8800 100644 --- a/servers/slapd/back-bdb/index.c +++ b/servers/slapd/back-bdb/index.c @@ -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; } diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index c770b3fc42..48f41659d1 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -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, -- 2.39.5