--- /dev/null
+Return-Path: <david@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 705EE6DE0C1E\r
+ for <notmuch@notmuchmail.org>; Thu, 24 Sep 2015 05:34:22 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.112\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.112 tagged_above=-999 required=5 tests=[AWL=0.112]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id BVL9venosmGo for <notmuch@notmuchmail.org>;\r
+ Thu, 24 Sep 2015 05:34:20 -0700 (PDT)\r
+Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 3C4C06DE0B7C\r
+ for <notmuch@notmuchmail.org>; Thu, 24 Sep 2015 05:34:20 -0700 (PDT)\r
+Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
+ (envelope-from <david@tethera.net>)\r
+ id 1Zf5hQ-0006ga-I3; Thu, 24 Sep 2015 12:32:32 +0000\r
+Received: (nullmailer pid 9111 invoked by uid 1000); Thu, 24 Sep 2015\r
+ 12:32:13 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2 6/9] cli: change the data structure for notmuch\r
+ address deduplication\r
+In-Reply-To:\r
+ <d8bb01aff648f9b73ec5f09f0e86e42dac2a21a6.1441308761.git.jani@nikula.org>\r
+References: <cover.1441308761.git.jani@nikula.org>\r
+ <d8bb01aff648f9b73ec5f09f0e86e42dac2a21a6.1441308761.git.jani@nikula.org>\r
+User-Agent: Notmuch/0.20.2+73~gd432116 (http://notmuchmail.org) Emacs/24.5.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Thu, 24 Sep 2015 09:32:13 -0300\r
+Message-ID: <87fv242e2a.fsf@zancas.localnet>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 24 Sep 2015 12:34:22 -0000\r
+\r
+Jani Nikula <jani@nikula.org> writes:\r
+\r
+\r
+> + else\r
+> + v = !!m1->name - !!m2->name;\r
+\r
+Is this really idiomatic? It seems a little difficult to follow to me.\r
+\r
+> /* Returns TRUE iff name and addr is duplicate. If not, stores the\r
+> * name/addr pair in order to detect subsequent duplicates. */\r
+> static notmuch_bool_t\r
+> is_duplicate (const search_context_t *ctx, const char *name, const char *addr)\r
+> {\r
+> char *key;\r
+> + GList *list, *l;\r
+> mailbox_t *mailbox;\r
+> \r
+> - key = talloc_asprintf (ctx->format, "%s <%s>", name, addr);\r
+> - if (! key)\r
+> - return FALSE;\r
+> + list = g_hash_table_lookup (ctx->addresses, addr);\r
+> + if (list) {\r
+> + mailbox_t find = {\r
+> + .name = name,\r
+> + .addr = addr,\r
+> + };\r
+> +\r
+> + l = g_list_find_custom (list, &find, mailbox_compare);\r
+> + if (l) {\r
+> + mailbox = l->data;\r
+> + mailbox->count++;\r
+> + return TRUE;\r
+> + }\r
+> \r
+> - mailbox = g_hash_table_lookup (ctx->addresses, key);\r
+> - if (mailbox) {\r
+> - mailbox->count++;\r
+> - talloc_free (key);\r
+> - return TRUE;\r
+> + mailbox = new_mailbox (ctx->format, name, addr);\r
+> + if (! mailbox)\r
+> + return FALSE;\r
+> +\r
+> + /*\r
+> + * XXX: It would be more efficient to prepend to the list, but\r
+> + * then we'd have to store the changed list head back to the\r
+> + * hash table. This check is here just to avoid the compiler\r
+> + * warning for unused result.\r
+> + */\r
+> + if (list != g_list_append (list, mailbox))\r
+> + INTERNAL_ERROR ("appending to list changed list head\n");\r
+> +\r
+> + return FALSE;\r
+> }\r
+> \r
+> + key = talloc_strdup (ctx->format, addr);\r
+> + if (! key)\r
+> + return FALSE;\r
+> +\r
+> mailbox = new_mailbox (ctx->format, name, addr);\r
+> if (! mailbox)\r
+> return FALSE;\r
+> \r
+> - g_hash_table_insert (ctx->addresses, key, mailbox);\r
+> + list = g_list_append (NULL, mailbox);\r
+> + if (! list)\r
+> + return FALSE;\r
+> +\r
+> + g_hash_table_insert (ctx->addresses, key, list);\r
+> \r
+> return FALSE;\r
+> }\r
+> @@ -401,12 +445,21 @@ _talloc_free_for_g_hash (void *ptr)\r
+> }\r
+> \r
+> static void\r
+> -print_hash_value (unused (gpointer key), gpointer value, gpointer user_data)\r
+> +_list_free_for_g_hash (void *ptr)\r
+> +{\r
+> + g_list_free_full (ptr, _talloc_free_for_g_hash);\r
+> +}\r
+> +\r
+> +static void\r
+> +print_list_value (void *mailbox, void *context)\r
+> {\r
+> - const mailbox_t *mailbox = value;\r
+> - search_context_t *ctx = user_data;\r
+> + print_mailbox (context, mailbox);\r
+> +}\r
+> \r
+> - print_mailbox (ctx, mailbox);\r
+> +static void\r
+> +print_hash_value (unused (void *key), void *list, void *context)\r
+> +{\r
+> + g_list_foreach (list, print_list_value, context);\r
+> }\r
+> \r
+> static int\r
+> @@ -792,8 +845,9 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])\r
+> argc - opt_index, argv + opt_index))\r
+> return EXIT_FAILURE;\r
+> \r
+> - ctx->addresses = g_hash_table_new_full (g_str_hash, g_str_equal,\r
+> - _talloc_free_for_g_hash, _talloc_free_for_g_hash);\r
+> + ctx->addresses = g_hash_table_new_full (strcase_hash, strcase_equal,\r
+> + _talloc_free_for_g_hash,\r
+> + _list_free_for_g_hash);\r
+> \r
+> ret = do_search_messages (ctx);\r
+> \r
+> -- \r
+> 2.1.4\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r