aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2009-11-23 20:12:57 -0800
committerGravatar Carl Worth <cworth@cworth.org>2009-11-23 20:17:37 -0800
commit1fd8b7866f189a66e4491b01452f476371759f91 (patch)
tree9ba352943bb700f093946f3070c69bae6b568455 /lib
parentf6158039324e44159d449b459829dc7ad4e52acc (diff)
notmuch search: Remove the chunked-searching hack.
This was a poor workaround around the fact that the existing notmuch_threads_t object is implemented poorly. It's got a fine iterartor-based interface, but the implementation does all of the work up-front in _create rather than doing the work incrementally while iterating. So to start fixing this, first get rid of all the hacks we had working around this. This drops the --first and --max-threads options from the search command, (but hopefully nobody was using them anyway---notmuch.el certainly wasn't).
Diffstat (limited to 'lib')
-rw-r--r--lib/notmuch.h11
-rw-r--r--lib/query.cc57
2 files changed, 17 insertions, 51 deletions
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 260cc22d..9b40fb69 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -322,14 +322,6 @@ notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
* object is owned by the query and as such, will only be valid until
* notmuch_query_destroy.
*
- * The 'first' and 'max_threads' arguments can be used to obtain
- * partial results from the search. For example, to get results 10 at
- * a time, pass 'max_threads' as 10 and for 'first' pass the values 0,
- * 10, 20, etc. As a special case, a value of -1 for 'max_threads'
- * indicates that no limiting is to be performed. So a search with
- * 'first' == 0 and 'max_threads' == -1 will return the complete
- * results of the search.
- *
* Typical usage might be:
*
* notmuch_query_t *query;
@@ -362,8 +354,7 @@ notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
* to call it if the query is about to be destroyed).
*/
notmuch_threads_t *
-notmuch_query_search_threads (notmuch_query_t *query,
- int first, int max_threads);
+notmuch_query_search_threads (notmuch_query_t *query);
/* Execute a query for messages, returning a notmuch_messages_t object
* which can be used to iterate over the results. The returned
diff --git a/lib/query.cc b/lib/query.cc
index 686d75f9..13bdd0a1 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -171,9 +171,7 @@ _notmuch_threads_destructor (notmuch_threads_t *threads)
}
notmuch_threads_t *
-notmuch_query_search_threads (notmuch_query_t *query,
- int first,
- int max_threads)
+notmuch_query_search_threads (notmuch_query_t *query)
{
notmuch_threads_t *threads;
notmuch_thread_t *thread;
@@ -181,7 +179,6 @@ notmuch_query_search_threads (notmuch_query_t *query,
notmuch_messages_t *messages;
notmuch_message_t *message;
GHashTable *seen;
- int messages_seen = 0, threads_seen = 0;
threads = talloc (query, notmuch_threads_t);
if (threads == NULL)
@@ -196,49 +193,27 @@ notmuch_query_search_threads (notmuch_query_t *query,
seen = g_hash_table_new_full (g_str_hash, g_str_equal,
free, NULL);
- while (max_threads < 0 || threads_seen < first + max_threads)
+ for (messages = notmuch_query_search_messages (query, 0, -1);
+ notmuch_messages_has_more (messages);
+ notmuch_messages_advance (messages))
{
- int messages_seen_previously = messages_seen;
+ message = notmuch_messages_get (messages);
- for (messages = notmuch_query_search_messages (query,
- messages_seen,
- max_threads);
- notmuch_messages_has_more (messages);
- notmuch_messages_advance (messages))
- {
- message = notmuch_messages_get (messages);
-
- thread_id = notmuch_message_get_thread_id (message);
-
- if (! g_hash_table_lookup_extended (seen,
- thread_id, NULL,
- (void **) &thread))
- {
- if (threads_seen >= first) {
- thread = _notmuch_thread_create (query, query->notmuch,
- thread_id,
- query->query_string);
- g_ptr_array_add (threads->threads, thread);
- } else {
- thread = NULL;
- }
-
- g_hash_table_insert (seen, xstrdup (thread_id), thread);
-
- threads_seen++;
- }
+ thread_id = notmuch_message_get_thread_id (message);
- notmuch_message_destroy (message);
-
- messages_seen++;
+ if (! g_hash_table_lookup_extended (seen,
+ thread_id, NULL,
+ (void **) &thread))
+ {
+ thread = _notmuch_thread_create (query, query->notmuch,
+ thread_id,
+ query->query_string);
+ g_ptr_array_add (threads->threads, thread);
- if (max_threads >= 0 && threads_seen >= first + max_threads)
- break;
+ g_hash_table_insert (seen, xstrdup (thread_id), thread);
}
- /* Stop if we're not seeing any more messages. */
- if (messages_seen == messages_seen_previously)
- break;
+ notmuch_message_destroy (message);
}
g_hash_table_unref (seen);