mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
lib: Fix RegexpPostingSource
Remove incorrect skipping to first match from init(), and add explicit skip_to() and check() methods to work around xapian-core bug (the check() method will also improve speed when filtering by one of these).
This commit is contained in:
parent
9208289eea
commit
81bd72cebb
2 changed files with 23 additions and 5 deletions
|
@ -62,11 +62,6 @@ RegexpPostingSource::init (const Xapian::Database &db)
|
||||||
it_ = db_.valuestream_begin (slot_);
|
it_ = db_.valuestream_begin (slot_);
|
||||||
end_ = db.valuestream_end (slot_);
|
end_ = db.valuestream_end (slot_);
|
||||||
started_ = false;
|
started_ = false;
|
||||||
|
|
||||||
/* make sure we start on a matching value */
|
|
||||||
while (!at_end() && regexec (®exp_, (*it_).c_str (), 0, NULL, 0) != 0) {
|
|
||||||
++it_;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Xapian::doccount
|
Xapian::doccount
|
||||||
|
@ -113,6 +108,27 @@ RegexpPostingSource::next (unused (double min_wt))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
RegexpPostingSource::skip_to (Xapian::docid did, unused (double min_wt))
|
||||||
|
{
|
||||||
|
started_ = true;
|
||||||
|
it_.skip_to (did);
|
||||||
|
for (; ! at_end (); ++it_) {
|
||||||
|
std::string value = *it_;
|
||||||
|
if (regexec (®exp_, value.c_str (), 0, NULL, 0) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
RegexpPostingSource::check (Xapian::docid did, unused (double min_wt))
|
||||||
|
{
|
||||||
|
started_ = true;
|
||||||
|
if (!it_.check (did) || at_end ())
|
||||||
|
return false;
|
||||||
|
return (regexec (®exp_, (*it_).c_str (), 0, NULL, 0) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
static inline Xapian::valueno _find_slot (std::string prefix)
|
static inline Xapian::valueno _find_slot (std::string prefix)
|
||||||
{
|
{
|
||||||
if (prefix == "from")
|
if (prefix == "from")
|
||||||
|
|
|
@ -56,6 +56,8 @@ class RegexpPostingSource : public Xapian::PostingSource
|
||||||
Xapian::docid get_docid () const;
|
Xapian::docid get_docid () const;
|
||||||
bool at_end () const;
|
bool at_end () const;
|
||||||
void next (unused (double min_wt));
|
void next (unused (double min_wt));
|
||||||
|
void skip_to (Xapian::docid did, unused (double min_wt));
|
||||||
|
bool check (Xapian::docid did, unused (double min_wt));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue