1 Return-Path: <david@tethera.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id 705EE6DE0C1E
\r
6 for <notmuch@notmuchmail.org>; Thu, 24 Sep 2015 05:34:22 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0.112 tagged_above=-999 required=5 tests=[AWL=0.112]
\r
13 Received: from arlo.cworth.org ([127.0.0.1])
\r
14 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id BVL9venosmGo for <notmuch@notmuchmail.org>;
\r
16 Thu, 24 Sep 2015 05:34:20 -0700 (PDT)
\r
17 Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])
\r
18 by arlo.cworth.org (Postfix) with ESMTPS id 3C4C06DE0B7C
\r
19 for <notmuch@notmuchmail.org>; Thu, 24 Sep 2015 05:34:20 -0700 (PDT)
\r
20 Received: from remotemail by gitolite.debian.net with local (Exim 4.80)
\r
21 (envelope-from <david@tethera.net>)
\r
22 id 1Zf5hQ-0006ga-I3; Thu, 24 Sep 2015 12:32:32 +0000
\r
23 Received: (nullmailer pid 9111 invoked by uid 1000); Thu, 24 Sep 2015
\r
25 From: David Bremner <david@tethera.net>
\r
26 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org
\r
27 Subject: Re: [PATCH v2 6/9] cli: change the data structure for notmuch
\r
28 address deduplication
\r
30 <d8bb01aff648f9b73ec5f09f0e86e42dac2a21a6.1441308761.git.jani@nikula.org>
\r
31 References: <cover.1441308761.git.jani@nikula.org>
\r
32 <d8bb01aff648f9b73ec5f09f0e86e42dac2a21a6.1441308761.git.jani@nikula.org>
\r
33 User-Agent: Notmuch/0.20.2+73~gd432116 (http://notmuchmail.org) Emacs/24.5.1
\r
34 (x86_64-pc-linux-gnu)
\r
35 Date: Thu, 24 Sep 2015 09:32:13 -0300
\r
36 Message-ID: <87fv242e2a.fsf@zancas.localnet>
\r
38 Content-Type: text/plain
\r
39 X-BeenThere: notmuch@notmuchmail.org
\r
40 X-Mailman-Version: 2.1.18
\r
42 List-Id: "Use and development of the notmuch mail system."
\r
43 <notmuch.notmuchmail.org>
\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
47 List-Post: <mailto:notmuch@notmuchmail.org>
\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
51 X-List-Received-Date: Thu, 24 Sep 2015 12:34:22 -0000
\r
53 Jani Nikula <jani@nikula.org> writes:
\r
57 > + v = !!m1->name - !!m2->name;
\r
59 Is this really idiomatic? It seems a little difficult to follow to me.
\r
61 > /* Returns TRUE iff name and addr is duplicate. If not, stores the
\r
62 > * name/addr pair in order to detect subsequent duplicates. */
\r
63 > static notmuch_bool_t
\r
64 > is_duplicate (const search_context_t *ctx, const char *name, const char *addr)
\r
67 > + GList *list, *l;
\r
68 > mailbox_t *mailbox;
\r
70 > - key = talloc_asprintf (ctx->format, "%s <%s>", name, addr);
\r
73 > + list = g_hash_table_lookup (ctx->addresses, addr);
\r
75 > + mailbox_t find = {
\r
80 > + l = g_list_find_custom (list, &find, mailbox_compare);
\r
82 > + mailbox = l->data;
\r
83 > + mailbox->count++;
\r
87 > - mailbox = g_hash_table_lookup (ctx->addresses, key);
\r
89 > - mailbox->count++;
\r
90 > - talloc_free (key);
\r
92 > + mailbox = new_mailbox (ctx->format, name, addr);
\r
97 > + * XXX: It would be more efficient to prepend to the list, but
\r
98 > + * then we'd have to store the changed list head back to the
\r
99 > + * hash table. This check is here just to avoid the compiler
\r
100 > + * warning for unused result.
\r
102 > + if (list != g_list_append (list, mailbox))
\r
103 > + INTERNAL_ERROR ("appending to list changed list head\n");
\r
108 > + key = talloc_strdup (ctx->format, addr);
\r
112 > mailbox = new_mailbox (ctx->format, name, addr);
\r
116 > - g_hash_table_insert (ctx->addresses, key, mailbox);
\r
117 > + list = g_list_append (NULL, mailbox);
\r
121 > + g_hash_table_insert (ctx->addresses, key, list);
\r
125 > @@ -401,12 +445,21 @@ _talloc_free_for_g_hash (void *ptr)
\r
129 > -print_hash_value (unused (gpointer key), gpointer value, gpointer user_data)
\r
130 > +_list_free_for_g_hash (void *ptr)
\r
132 > + g_list_free_full (ptr, _talloc_free_for_g_hash);
\r
136 > +print_list_value (void *mailbox, void *context)
\r
138 > - const mailbox_t *mailbox = value;
\r
139 > - search_context_t *ctx = user_data;
\r
140 > + print_mailbox (context, mailbox);
\r
143 > - print_mailbox (ctx, mailbox);
\r
145 > +print_hash_value (unused (void *key), void *list, void *context)
\r
147 > + g_list_foreach (list, print_list_value, context);
\r
151 > @@ -792,8 +845,9 @@ notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])
\r
152 > argc - opt_index, argv + opt_index))
\r
153 > return EXIT_FAILURE;
\r
155 > - ctx->addresses = g_hash_table_new_full (g_str_hash, g_str_equal,
\r
156 > - _talloc_free_for_g_hash, _talloc_free_for_g_hash);
\r
157 > + ctx->addresses = g_hash_table_new_full (strcase_hash, strcase_equal,
\r
158 > + _talloc_free_for_g_hash,
\r
159 > + _list_free_for_g_hash);
\r
161 > ret = do_search_messages (ctx);
\r
166 > _______________________________________________
\r
167 > notmuch mailing list
\r
168 > notmuch@notmuchmail.org
\r
169 > http://notmuchmail.org/mailman/listinfo/notmuch
\r