diff options
author | Carl Worth <cworth@cworth.org> | 2009-12-21 15:12:52 -0800 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-01-06 10:32:06 -0800 |
commit | 44a74912c78526c1942a101a8172206a32885425 (patch) | |
tree | ae3c16355cedc0a9b36a2e220a06ac0adddad63f /lib/database.cc | |
parent | d7e5f5827e21be7dd8993e5a877bdb73cdb64325 (diff) |
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.
Diffstat (limited to 'lib/database.cc')
-rw-r--r-- | lib/database.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/database.cc b/lib/database.cc index 5d300732..cd3346fd 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -214,21 +214,29 @@ 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, const char *value, 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); } |