X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fdirectory.cc;h=70e1693ea54eaa4f3bfe5e5312610318d803621f;hp=16492c0d754d9bf6ccfaf46c3ed96b2519410c50;hb=08f7b026a9f8a32fbe14eb73b99a026544b22900;hpb=d87db8843266caf6b11c1f2f1874328830b23878 diff --git a/lib/directory.cc b/lib/directory.cc index 16492c0d..70e1693e 100644 --- a/lib/directory.cc +++ b/lib/directory.cc @@ -23,37 +23,23 @@ /* 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, notmuch_database_t *notmuch, const char *prefix) { - notmuch_filenames_t *filenames; + notmuch_string_list_t *filename_list; Xapian::TermIterator i, end; - int prefix_len = strlen (prefix); - filenames = _notmuch_filenames_create (ctx); - if (unlikely (filenames == NULL)) + 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_filenames_add_filename (filenames, term.c_str () + - prefix_len); - } - - _notmuch_filenames_move_to_first (filenames); - - return filenames; + return _notmuch_filenames_create (ctx, filename_list); } struct _notmuch_directory {