]> git.cworth.org Git - notmuch/commitdiff
cli: do not sort addresses on --output=count or --deduplicate=address
authorJani Nikula <jani@nikula.org>
Thu, 3 Sep 2015 19:40:05 +0000 (22:40 +0300)
committerDavid Bremner <david@tethera.net>
Sat, 26 Sep 2015 10:41:05 +0000 (07:41 -0300)
The order of the results with --output=count and --deduplicate=address
are unspecified as they're based on a hash table traversal. This being
the case, optimize the query by explicitly requesting unsorted
results. Clarify the documentation accordingly.

doc/man1/notmuch-address.rst
notmuch-search.c

index 935851ef9ac32e1fcda8b3719749c44d80d8de0e..7f7214b32fb3e25a91c0bb6bc5464d94b13c6254 100644 (file)
@@ -85,7 +85,9 @@ Supported options for **address** include
         By default, results will be displayed in reverse chronological
         order, (that is, the newest results will be displayed first).
 
-        This option is not supported with --output=count.
+        However, if either --output=count or --deduplicate=address is
+        specified, this option is ignored and the order of the results
+        is unspecified.
 
     ``--exclude=(true|false)``
         A message is called "excluded" if it matches at least one tag in
index 2eaad32f2abbbeee75eea79fb4f34a1ddb4f83d7..44e582cbf416acb42f683609fd9f2491c6dca035 100644 (file)
@@ -883,6 +883,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);