]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts-flatcurve: Extract fts_flatcurve_build_add_maybe_query() into a function
authorMichael M Slusarz <michael.slusarz@open-xchange.com>
Mon, 4 May 2026 22:43:06 +0000 (16:43 -0600)
committerMichael M Slusarz <michael.slusarz@open-xchange.com>
Mon, 11 May 2026 20:20:07 +0000 (14:20 -0600)
src/plugins/fts-flatcurve/fts-backend-flatcurve-xapian.cc

index 32f79f40cafa00e1e768cf4be246afe6f26a748b..e34775531f1e043aedcda24ea72c4841042787b4 100644 (file)
@@ -1986,6 +1986,19 @@ int fts_flatcurve_xapian_optimize_box(struct flatcurve_fts_backend *backend,
        return ret;
 }
 
+static void
+fts_flatcurve_build_add_maybe_query(struct flatcurve_fts_query *query,
+                                   Xapian::Query *q)
+{
+       struct flatcurve_fts_query_xapian_maybe *mquery;
+       struct flatcurve_fts_query_xapian *x = query->xapian;
+
+       if (!array_is_created(&x->maybe_queries))
+               p_array_init(&x->maybe_queries, query->pool, 4);
+       mquery = array_append_space(&x->maybe_queries);
+       mquery->query = q;
+}
+
 static void
 fts_flatcurve_build_query_arg_term(struct flatcurve_fts_query *query,
                                   struct mail_search_arg *arg,
@@ -1993,7 +2006,6 @@ fts_flatcurve_build_query_arg_term(struct flatcurve_fts_query *query,
 {
        const char *hdr;
        bool maybe_or = FALSE;
-       struct flatcurve_fts_query_xapian_maybe *mquery;
        Xapian::Query::op op = Xapian::Query::OP_INVALID;
        Xapian::Query *oldq, q;
        struct flatcurve_fts_query_xapian *x = query->xapian;
@@ -2084,10 +2096,8 @@ fts_flatcurve_build_query_arg_term(struct flatcurve_fts_query *query,
                /* Maybe searches are not added to the "master search" query if this
                 * is an OR search; they will be run independently. Matches will be
                 * placed in the maybe results array. */
-               if (!array_is_created(&x->maybe_queries))
-                       p_array_init(&x->maybe_queries, query->pool, 4);
-               mquery = array_append_space(&x->maybe_queries);
-               mquery->query = new Xapian::Query(std_move(q));
+               fts_flatcurve_build_add_maybe_query(query,
+                                                   new Xapian::Query(std_move(q)));
        } else if (x->query == NULL) {
                x->query = new Xapian::Query(std_move(q));
        } else {