Ticket #174: check-at-least.patch

File check-at-least.patch, 1.5 KB (added by Olly Betts, 17 years ago)

Patch

  • matcher/multimatch.cc

     
    348348
    349349    // Set max number of results that we want - this is used to decide
    350350    // when to throw away unwanted items.
    351     Xapian::doccount max_msize = first + check_at_least;
     351    Xapian::doccount max_msize = first + maxitems;
    352352    items.reserve(max_msize + 1);
    353353
    354354    // Tracks the minimum item currently eligible for the MSet - we compare
     
    560560
    561561                min_item = items.front();
    562562                if (sort_by == REL || sort_by == REL_VAL) {
    563                     if (min_item.wt > min_weight) min_weight = min_item.wt;
     563                    if (docs_matched >= check_at_least) {
     564                        if (min_item.wt > min_weight) min_weight = min_item.wt;
     565                    }
    564566                }
    565567                if (getorrecalc_maxweight(pl) < min_weight) {
    566568                    DEBUGLINE(MATCH, "*** TERMINATING EARLY (3)");
     
    742744
    743745    DEBUGLINE(MATCH, items.size() << " items in potential mset");
    744746
    745     if (check_at_least > maxitems) {
    746         // Remove unwanted trailing entries
    747         if (maxitems == 0) {
    748             items.clear();
    749         } else if (items.size() > first + maxitems) {
    750             nth_element(items.begin(),
    751                         items.begin() + first + maxitems,
    752                         items.end(),
    753                         mcmp);
    754             // Erase the unwanted trailing items.
    755             items.erase(items.begin() + first + maxitems, items.end());
    756         }
    757     }
    758747    if (first > 0) {
    759748        // Remove unwanted leading entries
    760749        if (items.size() <= first) {