]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-search.c
Merge branch 'release'
[notmuch] / notmuch-search.c
index 2eaad32f2abbbeee75eea79fb4f34a1ddb4f83d7..8c65d5ad196d7705fca8142eac5199bae9c658b2 100644 (file)
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see http://www.gnu.org/licenses/ .
+ * along with this program.  If not, see https://www.gnu.org/licenses/ .
  *
  * Author: Carl Worth <cworth@cworth.org>
  */
@@ -121,7 +121,13 @@ do_search_threads (search_context_t *ctx)
     notmuch_status_t status;
 
     if (ctx->offset < 0) {
-       ctx->offset += notmuch_query_count_threads (ctx->query);
+       unsigned count;
+       notmuch_status_t status;
+       status = notmuch_query_count_threads_st (ctx->query, &count);
+       if (print_status_query ("notmuch search", ctx->query, status))
+           return 1;
+
+       ctx->offset += count;
        if (ctx->offset < 0)
            ctx->offset = 0;
     }
@@ -521,7 +527,13 @@ do_search_messages (search_context_t *ctx)
     notmuch_status_t status;
 
     if (ctx->offset < 0) {
-       ctx->offset += notmuch_query_count_messages (ctx->query);
+       unsigned count;
+       notmuch_status_t status;
+       status = notmuch_query_count_messages_st (ctx->query, &count);
+       if (print_status_query ("notmuch search", ctx->query, status))
+           return 1;
+
+       ctx->offset += count;
        if (ctx->offset < 0)
            ctx->offset = 0;
     }
@@ -883,6 +895,11 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])
                                            _talloc_free_for_g_hash,
                                            _list_free_for_g_hash);
 
+    /* The order is not guaranteed if a full pass is required, so go
+     * for fastest. */
+    if (ctx->output & OUTPUT_COUNT || ctx->dedup == DEDUP_ADDRESS)
+       notmuch_query_set_sort (ctx->query, NOTMUCH_SORT_UNSORTED);
+
     ret = do_search_messages (ctx);
 
     g_hash_table_unref (ctx->addresses);