1 Return-Path: <amdragon@mit.edu>
\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 olra.theworths.org (Postfix) with ESMTP id 59BD9431FAF
\r
6 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 20:57:21 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id p-g33t5ItADr for <notmuch@notmuchmail.org>;
\r
16 Sat, 24 Nov 2012 20:57:20 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 8F525431FBF
\r
20 for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 20:57:19 -0800 (PST)
\r
21 X-AuditID: 12074424-b7fce6d000000925-3c-50b1a52e6a56
\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
23 by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id C0.DA.02341.E25A1B05; Sat, 24 Nov 2012 23:57:18 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id qAP4vHTg018857;
\r
27 Sat, 24 Nov 2012 23:57:17 -0500
\r
28 Received: from drake.dyndns.org
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qAP4vEDW000082
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Sat, 24 Nov 2012 23:57:16 -0500 (EST)
\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
36 (envelope-from <amdragon@mit.edu>)
\r
37 id 1TcUHJ-0003Zn-Ss; Sat, 24 Nov 2012 23:57:13 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 2/6] lib: Separate list of all messages from top-level
\r
42 Date: Sat, 24 Nov 2012 23:57:03 -0500
\r
43 Message-Id: <1353819427-13182-3-git-send-email-amdragon@mit.edu>
\r
44 X-Mailer: git-send-email 1.7.10.4
\r
45 In-Reply-To: <1353819427-13182-1-git-send-email-amdragon@mit.edu>
\r
46 References: <1353819427-13182-1-git-send-email-amdragon@mit.edu>
\r
47 X-Brightmail-Tracker:
\r
48 H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsUixCmqrau3dGOAweR/shar5/JYXL85k9mB
\r
49 yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgytjYNY294L9cxarT95gaGF9JdDFyckgImEis
\r
50 +HqDDcIWk7hwbz2QzcUhJLCPUeLEjrPsEM4GRolHZ86zQjiPmCS2nrkFVTaXUWJz81kWkH42
\r
51 AQ2JbfuXM4LYIgLSEjvvzmYFsZkFHCU+718EtkNYwF/i/r4msDiLgKrEyU07wWxeAQeJuXd2
\r
52 M0LcoSjR/WwCUD0HBydQb+NeOZCwEFDJrX+TmCcw8i9gZFjFKJuSW6Wbm5iZU5yarFucnJiX
\r
53 l1qka66Xm1mil5pSuokRFEjsLio7GJsPKR1iFOBgVOLhvZG4MUCINbGsuDL3EKMkB5OSKG/m
\r
54 IqAQX1J+SmVGYnFGfFFpTmrxIUYJDmYlEV5rVaAcb0piZVVqUT5MSpqDRUmc93rKTX8hgfTE
\r
55 ktTs1NSC1CKYrAwHh5IEr8gSoEbBotT01Iq0zJwShDQTByfIcB6g4aIgNbzFBYm5xZnpEPlT
\r
56 jIpS4rzmIAkBkERGaR5cLyzSXzGKA70izOsAUsUDTBJw3a+ABjMBDX46ex3I4JJEhJRUA2N0
\r
57 jJWA01Nd8wdnjjdWcTyZYXwo/NmhHB2WSSfqwtv2XvmqGyRiFpUvqiX5NeN8z9+61vid039c
\r
58 lXoUGp+5OMWOXXBWhZ/lXRaZKfUTWOeUd+yL4Vv088FH7irpc/4ec80FUm5ufriroEpi5X8V
\r
59 G6vURTMX3H66fsHXgJpj25quWLfrPWTic1FiKc5INNRiLipOBACvrW8czwIAAA==
\r
60 X-BeenThere: notmuch@notmuchmail.org
\r
61 X-Mailman-Version: 2.1.13
\r
63 List-Id: "Use and development of the notmuch mail system."
\r
64 <notmuch.notmuchmail.org>
\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
68 List-Post: <mailto:notmuch@notmuchmail.org>
\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
72 X-List-Received-Date: Sun, 25 Nov 2012 04:57:21 -0000
\r
74 Previously, thread.cc built up a list of all messages, then
\r
75 proceeded to tear it apart to transform it into a list of
\r
76 top-level messages. Now we simply build a new list of top-level
\r
79 This simplifies the interface to _notmuch_message_add_reply,
\r
80 eliminates the pointer acrobatics from
\r
81 _resolve_thread_relationships, and will enable us to do things
\r
82 with the list of all messages in the following patches.
\r
84 lib/message.cc | 4 ++--
\r
85 lib/notmuch-private.h | 2 +-
\r
86 lib/thread.cc | 29 ++++++++++++++---------------
\r
87 3 files changed, 17 insertions(+), 18 deletions(-)
\r
89 diff --git a/lib/message.cc b/lib/message.cc
\r
90 index 978de06..171c580 100644
\r
91 --- a/lib/message.cc
\r
92 +++ b/lib/message.cc
\r
93 @@ -462,9 +462,9 @@ notmuch_message_get_thread_id (notmuch_message_t *message)
\r
96 _notmuch_message_add_reply (notmuch_message_t *message,
\r
97 - notmuch_message_node_t *reply)
\r
98 + notmuch_message_t *reply)
\r
100 - _notmuch_message_list_append (message->replies, reply);
\r
101 + _notmuch_message_list_add_message (message->replies, reply);
\r
104 notmuch_messages_t *
\r
105 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
106 index 7a409f5..c054a0e 100644
\r
107 --- a/lib/notmuch-private.h
\r
108 +++ b/lib/notmuch-private.h
\r
109 @@ -462,7 +462,7 @@ _notmuch_doc_id_set_remove (notmuch_doc_id_set_t *doc_ids,
\r
112 _notmuch_message_add_reply (notmuch_message_t *message,
\r
113 - notmuch_message_node_t *reply);
\r
114 + notmuch_message_t *reply);
\r
118 diff --git a/lib/thread.cc b/lib/thread.cc
\r
119 index aed87b1..45a7d1d 100644
\r
120 --- a/lib/thread.cc
\r
121 +++ b/lib/thread.cc
\r
122 @@ -35,7 +35,11 @@ struct visible _notmuch_thread {
\r
126 + /* All messages, oldest first. */
\r
127 notmuch_message_list_t *message_list;
\r
128 + /* Top-level messages, oldest first. */
\r
129 + notmuch_message_list_t *toplevel_list;
\r
131 GHashTable *message_hash;
\r
132 int total_messages;
\r
133 int matched_messages;
\r
134 @@ -345,29 +349,22 @@ _thread_add_matched_message (notmuch_thread_t *thread,
\r
138 -_resolve_thread_relationships (unused (notmuch_thread_t *thread))
\r
139 +_resolve_thread_relationships (notmuch_thread_t *thread)
\r
141 - notmuch_message_node_t **prev, *node;
\r
142 + notmuch_message_node_t *node;
\r
143 notmuch_message_t *message, *parent;
\r
144 const char *in_reply_to;
\r
146 - prev = &thread->message_list->head;
\r
147 - while ((node = *prev)) {
\r
148 + for (node = thread->message_list->head; node; node = node->next) {
\r
149 message = node->message;
\r
150 in_reply_to = _notmuch_message_get_in_reply_to (message);
\r
151 if (in_reply_to && strlen (in_reply_to) &&
\r
152 g_hash_table_lookup_extended (thread->message_hash,
\r
154 (void **) &parent))
\r
156 - *prev = node->next;
\r
157 - if (thread->message_list->tail == &node->next)
\r
158 - thread->message_list->tail = prev;
\r
159 - node->next = NULL;
\r
160 - _notmuch_message_add_reply (parent, node);
\r
162 - prev = &((*prev)->next);
\r
164 + _notmuch_message_add_reply (parent, message);
\r
166 + _notmuch_message_list_add_message (thread->toplevel_list, message);
\r
169 /* XXX: After scanning through the entire list looking for parents
\r
170 @@ -451,7 +448,9 @@ _notmuch_thread_create (void *ctx,
\r
173 thread->message_list = _notmuch_message_list_create (thread);
\r
174 - if (unlikely (thread->message_list == NULL)) {
\r
175 + thread->toplevel_list = _notmuch_message_list_create (thread);
\r
176 + if (unlikely (thread->message_list == NULL ||
\r
177 + thread->toplevel_list == NULL)) {
\r
181 @@ -506,7 +505,7 @@ _notmuch_thread_create (void *ctx,
\r
182 notmuch_messages_t *
\r
183 notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread)
\r
185 - return _notmuch_messages_create (thread->message_list);
\r
186 + return _notmuch_messages_create (thread->toplevel_list);
\r