mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-01-03 15:21:41 +01:00
database: Add new find_doc_ids_for_term interface.
The existing find_doc_ids function is convenient when the caller doesn't want to be bothered constructing a term. But when the caller *does* have the term already, that interface is just wasteful. So we export a lower-level interface that maps a pre-constructed term to a document-ID iterators.
This commit is contained in:
parent
d7e5f5827e
commit
44a74912c7
1 changed files with 12 additions and 4 deletions
|
@ -213,6 +213,17 @@ notmuch_status_to_string (notmuch_status_t status)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
find_doc_ids_for_term (notmuch_database_t *notmuch,
|
||||
const char *term,
|
||||
Xapian::PostingIterator *begin,
|
||||
Xapian::PostingIterator *end)
|
||||
{
|
||||
*begin = notmuch->xapian_db->postlist_begin (term);
|
||||
|
||||
*end = notmuch->xapian_db->postlist_end (term);
|
||||
}
|
||||
|
||||
static void
|
||||
find_doc_ids (notmuch_database_t *notmuch,
|
||||
const char *prefix_name,
|
||||
|
@ -220,15 +231,12 @@ find_doc_ids (notmuch_database_t *notmuch,
|
|||
Xapian::PostingIterator *begin,
|
||||
Xapian::PostingIterator *end)
|
||||
{
|
||||
Xapian::PostingIterator i;
|
||||
char *term;
|
||||
|
||||
term = talloc_asprintf (notmuch, "%s%s",
|
||||
_find_prefix (prefix_name), value);
|
||||
|
||||
*begin = notmuch->xapian_db->postlist_begin (term);
|
||||
|
||||
*end = notmuch->xapian_db->postlist_end (term);
|
||||
find_doc_ids_for_term (notmuch, term, begin, end);
|
||||
|
||||
talloc_free (term);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue