diff --git a/lib/mu-query.cc b/lib/mu-query.cc index 59e997348..9cd88d478 100644 --- a/lib/mu-query.cc +++ b/lib/mu-query.cc @@ -49,7 +49,7 @@ struct Query::Private { MuMsgFieldId sortfieldid, QueryFlags qflags) const; Option run_threaded (QueryResults&& qres, Xapian::Enquire& enq, - QueryFlags qflags) const; + QueryFlags qflags, size_t maxnum) const; Option run_singular (const std::string& expr, MuMsgFieldId sortfieldid, QueryFlags qflags, size_t maxnum) const; Option run_related (const std::string& expr, MuMsgFieldId sortfieldid, @@ -127,7 +127,7 @@ struct ThreadKeyMaker: public Xapian::KeyMaker { Option Query::Private::run_threaded (QueryResults&& qres, Xapian::Enquire& enq, - QueryFlags qflags) const + QueryFlags qflags, size_t maxnum) const { const auto descending{any_of(qflags & QueryFlags::Descending)}; @@ -138,7 +138,7 @@ Query::Private::run_threaded (QueryResults&& qres, Xapian::Enquire& enq, DeciderInfo minfo; minfo.matches = qres.query_matches(); - auto mset{enq.get_mset(0, store_.size(), {}, + auto mset{enq.get_mset(0, maxnum, {}, make_thread_decider(qflags, minfo).get())}; mset.fetch(); @@ -170,7 +170,7 @@ Query::Private::run_singular (const std::string& expr, MuMsgFieldId sortfieldid, auto qres{QueryResults{mset, std::move(minfo.matches)}}; - return threading ? run_threaded(std::move(qres), enq, qflags) : qres; + return threading ? run_threaded(std::move(qres), enq, qflags, maxnum) : qres; } static Option @@ -217,7 +217,7 @@ Query::Private::run_related (const std::string& expr, MuMsgFieldId sortfieldid, const auto r_mset{r_enq.get_mset(0, threading ? store_.size() : maxnum, {}, make_related_decider(qflags, minfo).get())}; auto qres{QueryResults{r_mset, std::move(minfo.matches)}}; - return threading ? run_threaded(std::move(qres), r_enq, qflags) : qres; + return threading ? run_threaded(std::move(qres), r_enq, qflags, maxnum) : qres; }