]> git.sur5r.net Git - openldap/commitdiff
Streamline answerability test
authorHoward Chu <hyc@openldap.org>
Mon, 9 Jan 2006 16:22:55 +0000 (16:22 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 9 Jan 2006 16:22:55 +0000 (16:22 +0000)
servers/slapd/overlays/pcache.c

index 2187beccb213d076b1ec8a3eaaffc5311f99ca8b..5a5609baa7f0c11491aa50a12ba65b5a902f42d7 100644 (file)
@@ -879,22 +879,6 @@ get_attr_set(
        int num
 );
 
-static int
-is_temp_answerable(
-       int attr_set,
-       struct berval* tempstr,
-       query_manager* qm,
-       int template_id )
-{
-       QueryTemplate *qt = qm->templates + template_id;
-
-       if (attr_set != qt->attr_set_index) {
-               return 0;
-       }
-       return (qt->querystr.bv_len == tempstr->bv_len &&
-               strcasecmp(qt->querystr.bv_val, tempstr->bv_val) == 0);
-}
-
 static int
 filter2template(
        Operation               *op,
@@ -1278,14 +1262,15 @@ pcache_op_search(
 
        /* check for query containment */
        if (attr_set > -1) {
-               for (i=0; i<cm->numtemplates; i++) {
+               QueryTemplate *qt = qm->templates;
+               for (i=0; i<cm->numtemplates; i++, qt++) {
                        /* find if template i can potentially answer tempstr */
-                       if (!is_temp_answerable(attr_set, &tempstr, qm, i))
+                       if ( qt->attr_set_index != attr_set ||
+                               qt->querystr.bv_len != tempstr.bv_len ||
+                               strcasecmp( qt->querystr.bv_val, tempstr.bv_val ))
                                continue;
-                       if (attr_set == qm->templates[i].attr_set_index) {
-                               cacheable = 1;
-                               template_id = i;
-                       }
+                       cacheable = 1;
+                       template_id = i;
                        Debug( LDAP_DEBUG_NONE, "Entering QC, querystr = %s\n",
                                        op->ors_filterstr.bv_val, 0, 0 );
                        answerable = (*(qm->qcfunc))(qm, &query, i);