For Xapian >= 1.4.10 users, using `|=' will reduce allocations.
`|=' still works for Xapian 1.3.2 .. 1.4.9 users, and I'm not
sure if Xapian 1.2.x is relevant anymore, especially for our
new C++-only features.
While operator overloading is often confusing and frustrating to
me when reading someone else's code, the optimization seems worth
it since (AFAIK) there's no other way to get the allocation
reduction.
cf. Olly in xapian-discuss <
20250222043050.GA17282@survex.com>
try {
Xapian::Document doc = i->get_document();
std::string val = doc.get_value(column);
- *xqry = Xapian::Query(Xapian::Query::OP_OR, *xqry,
- Xapian::Query(
- Xapian::Query::OP_VALUE_RANGE,
- column, val, val));
+ // n.b. Xapian 1.4.10+ optimizes `|=' to reduce allocation.
+ // operator overloading is confusing, yes :<
+ *xqry |= Xapian::Query(Xapian::Query::OP_VALUE_RANGE,
+ column, val, val);
} catch (const Xapian::DatabaseModifiedError &e) {
cur_srch->db->reopen();
return ITER_RETRY;