From bbf4b8e4aec69b5684587b77bd0af743afd61eb1 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 12 Nov 2009 20:31:22 -0800 Subject: [PATCH] notmuch_query_search_threads: Avoid returning more threads than asked for. I thought it would be safe enough to return a few extra threads, (since we happened to already get the relevant messages out of the database). The problem is that then requires the caller to carefully read the number of threads returned and adjust its next "first" value accordingly. The interface is much simpler to use if we simply return exactly what is asked for and no more. --- lib/query.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/query.cc b/lib/query.cc index 4b4c80f4..381529b5 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -237,6 +237,9 @@ notmuch_query_search_threads (notmuch_query_t *query, notmuch_message_destroy (message); messages_seen++; + + if (max_threads >= 0 && threads_seen >= first + max_threads) + break; } /* Stop if we're not seeing any more messages. */ -- 2.43.0