1 Return-Path: <meskio@sindominio.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 olra.theworths.org (Postfix) with ESMTP id 9ACAF4196F2
\r
6 for <notmuch@notmuchmail.org>; Sun, 21 Mar 2010 14:30:20 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9] autolearn=ham
\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 uGMrN-Ivr3s6 for <notmuch@notmuchmail.org>;
\r
16 Sun, 21 Mar 2010 14:30:19 -0700 (PDT)
\r
17 Received: from flatline.sindominio.net (flatline.sindominio.net [82.144.4.26])
\r
18 by olra.theworths.org (Postfix) with ESMTP id EE37B431FC1
\r
19 for <notmuch@notmuchmail.org>; Sun, 21 Mar 2010 14:30:12 -0700 (PDT)
\r
20 Received: from localhost (localhost.localdomain [127.0.0.1])
\r
21 by flatline.sindominio.net (Postfix) with ESMTP id 1E966348093;
\r
22 Sun, 21 Mar 2010 22:30:12 +0100 (CET)
\r
23 X-Virus-Scanned: Debian amavisd-new at sindominio.net
\r
24 Received: from flatline.sindominio.net ([127.0.0.1])
\r
25 by localhost (flatline.sindominio.net [127.0.0.1]) (amavisd-new,
\r
27 with ESMTP id 05IfKiPJPeWe; Sun, 21 Mar 2010 22:29:54 +0100 (CET)
\r
28 Received: from blackspot (heal.cauterized.net [89.140.131.167])
\r
29 by flatline.sindominio.net (Postfix) with ESMTPA id EC32C348046;
\r
30 Sun, 21 Mar 2010 22:29:06 +0100 (CET)
\r
31 Received: by blackspot (Postfix, from userid 1000)
\r
32 id 7093C8BDFC; Sun, 21 Mar 2010 22:32:39 +0100 (CET)
\r
33 From: Ruben Pollan <meskio@sindominio.net>
\r
34 To: notmuch@notmuchmail.org
\r
35 Date: Sun, 21 Mar 2010 22:32:32 +0100
\r
36 Message-Id: <1269207153-3687-2-git-send-email-meskio@sindominio.net>
\r
37 X-Mailer: git-send-email 1.7.0
\r
38 In-Reply-To: <1269080605-5617-1-git-send-email-meskio@sindominio.net>
\r
39 References: <1269080605-5617-1-git-send-email-meskio@sindominio.net>
\r
40 Subject: [notmuch] [PATCH 1/2] Move the logic of threads iterator out of
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Sun, 21 Mar 2010 21:30:20 -0000
\r
56 The logic of notmuch_threads_move_to_next iterator was on
\r
57 notmuch_threads_valid function. Now notmuch_threads_valid just check if
\r
58 the iterator is valid and is notmuch_threads_move_to_next wich actually
\r
59 update the iterator.
\r
61 lib/query.cc | 54 ++++++++++++++++++++++++++++++------------------------
\r
62 1 files changed, 30 insertions(+), 24 deletions(-)
\r
64 diff --git a/lib/query.cc b/lib/query.cc
\r
65 index 9266d35..514a156 100644
\r
68 @@ -233,6 +233,7 @@ notmuch_threads_t *
\r
69 notmuch_query_search_threads (notmuch_query_t *query)
\r
71 notmuch_threads_t *threads;
\r
72 + notmuch_message_t *message;
\r
74 threads = talloc (query, notmuch_threads_t);
\r
75 if (threads == NULL)
\r
76 @@ -243,8 +244,17 @@ notmuch_query_search_threads (notmuch_query_t *query)
\r
79 threads->messages = notmuch_query_search_messages (query);
\r
80 + if (!notmuch_messages_valid (threads->messages))
\r
82 + threads->thread_id = NULL;
\r
86 - threads->thread_id = NULL;
\r
87 + message = notmuch_messages_get (threads->messages);
\r
88 + threads->thread_id = notmuch_message_get_thread_id (message);
\r
89 + g_hash_table_insert (threads->threads,
\r
90 + xstrdup (threads->thread_id),
\r
93 talloc_set_destructor (threads, _notmuch_threads_destructor);
\r
95 @@ -260,10 +270,25 @@ notmuch_query_destroy (notmuch_query_t *query)
\r
97 notmuch_threads_valid (notmuch_threads_t *threads)
\r
99 - notmuch_message_t *message;
\r
100 + return (threads->thread_id != NULL);
\r
103 +notmuch_thread_t *
\r
104 +notmuch_threads_get (notmuch_threads_t *threads)
\r
106 + if (! notmuch_threads_valid (threads))
\r
109 + return _notmuch_thread_create (threads->query,
\r
110 + threads->query->notmuch,
\r
111 + threads->thread_id,
\r
112 + threads->query->query_string);
\r
115 - if (threads->thread_id)
\r
118 +notmuch_threads_move_to_next (notmuch_threads_t *threads)
\r
120 + notmuch_message_t *message;
\r
122 while (notmuch_messages_valid (threads->messages))
\r
124 @@ -278,32 +303,13 @@ notmuch_threads_valid (notmuch_threads_t *threads)
\r
125 g_hash_table_insert (threads->threads,
\r
126 xstrdup (threads->thread_id), NULL);
\r
127 notmuch_messages_move_to_next (threads->messages);
\r
132 notmuch_messages_move_to_next (threads->messages);
\r
135 threads->thread_id = NULL;
\r
139 -notmuch_thread_t *
\r
140 -notmuch_threads_get (notmuch_threads_t *threads)
\r
142 - if (! notmuch_threads_valid (threads))
\r
145 - return _notmuch_thread_create (threads->query,
\r
146 - threads->query->notmuch,
\r
147 - threads->thread_id,
\r
148 - threads->query->query_string);
\r
152 -notmuch_threads_move_to_next (notmuch_threads_t *threads)
\r
154 - threads->thread_id = NULL;
\r