aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/directory.cc
diff options
context:
space:
mode:
authorGravatar Austin Clements <amdragon@mit.edu>2010-12-09 00:32:35 -0500
committerGravatar Austin Clements <amdragon@mit.edu>2011-03-21 02:45:18 -0400
commit206938ec9b4ddee28793f2f052a5314d6d7ab08d (patch)
tree90fd4a729c343cbd0232abcafd43f32be176974f /lib/directory.cc
parentf3c1eebfaf8526129ae6946cbcd44a3c602563d6 (diff)
Add a generic function to get a list of terms with some prefix.
Replace _notmuch_convert_tags with this and simplify _create_filenames_for_terms_with_prefix. This will also come in handy shortly to get the message file name list.
Diffstat (limited to 'lib/directory.cc')
-rw-r--r--lib/directory.cc19
1 files changed, 4 insertions, 15 deletions
diff --git a/lib/directory.cc b/lib/directory.cc
index aeee9caf..70e1693e 100644
--- a/lib/directory.cc
+++ b/lib/directory.cc
@@ -23,10 +23,6 @@
/* Create an iterator to iterate over the basenames of files (or
* directories) that all share a common parent directory.
- *
- * The code here is general enough to be reused for any case of
- * iterating over the non-prefixed portion of terms sharing a common
- * prefix.
*/
static notmuch_filenames_t *
_create_filenames_for_terms_with_prefix (void *ctx,
@@ -35,21 +31,14 @@ _create_filenames_for_terms_with_prefix (void *ctx,
{
notmuch_string_list_t *filename_list;
Xapian::TermIterator i, end;
- int prefix_len = strlen (prefix);
- filename_list = _notmuch_string_list_create (ctx);
+ i = notmuch->xapian_db->allterms_begin();
+ end = notmuch->xapian_db->allterms_end();
+ filename_list = _notmuch_database_get_terms_with_prefix (ctx, i, end,
+ prefix);
if (unlikely (filename_list == NULL))
return NULL;
- end = notmuch->xapian_db->allterms_end (prefix);
-
- for (i = notmuch->xapian_db->allterms_begin (prefix); i != end; i++)
- {
- std::string term = *i;
-
- _notmuch_string_list_append (filename_list, term.c_str () + prefix_len);
- }
-
return _notmuch_filenames_create (ctx, filename_list);
}