RE: [Spam-verdenking][english 100%] Re: another bug fix release: 0.15.2, in progress.
[notmuch-archives.git] / 56 / 0037dd2ef34024ea25cd012227a0c5072f2b42
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 BBE46414BBF\r
6         for <notmuch@notmuchmail.org>; Sat, 20 Mar 2010 03:21:57 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.9\r
10 X-Spam-Level: \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 OXGae9Lxykvr for <notmuch@notmuchmail.org>;\r
16         Sat, 20 Mar 2010 03:21:56 -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 D518D41733B\r
19         for <notmuch@notmuchmail.org>; Sat, 20 Mar 2010 03:21:55 -0700 (PDT)\r
20 Received: from localhost (localhost.localdomain [127.0.0.1])\r
21         by flatline.sindominio.net (Postfix) with ESMTP id 0E421262E3E;\r
22         Sat, 20 Mar 2010 11:21:55 +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
26         port 10024)\r
27         with ESMTP id GXC1uBHjRNEL; Sat, 20 Mar 2010 11:21:50 +0100 (CET)\r
28 Received: from blackspot (heal.cauterized.net [89.140.131.167])\r
29         by flatline.sindominio.net (Postfix) with ESMTPA id 0B9BB262E3B;\r
30         Sat, 20 Mar 2010 11:21:43 +0100 (CET)\r
31 Received: by blackspot (Postfix, from userid 1000)\r
32         id B1AB18BDFD; Sat, 20 Mar 2010 11:24:53 +0100 (CET)\r
33 From: Ruben Pollan <meskio@sindominio.net>\r
34 To: notmuch@notmuchmail.org\r
35 Date: Sat, 20 Mar 2010 11:23:23 +0100\r
36 Message-Id: <1269080605-5617-4-git-send-email-meskio@sindominio.net>\r
37 X-Mailer: git-send-email 1.7.0\r
38 In-Reply-To: <873a09jt2t.fsf@yoom.home.cworth.org>\r
39 References: <873a09jt2t.fsf@yoom.home.cworth.org>\r
40 Subject: [notmuch] [PATCH 3/5] Move the logic of threads iterator out of\r
41         'valid'\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\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: Sat, 20 Mar 2010 10:21:57 -0000\r
55 \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
60 ---\r
61  lib/query.cc |   47 ++++++++++++++++++++++++-----------------------\r
62  1 files changed, 24 insertions(+), 23 deletions(-)\r
63 \r
64 diff --git a/lib/query.cc b/lib/query.cc\r
65 index 970c35a..44950c1 100644\r
66 --- a/lib/query.cc\r
67 +++ b/lib/query.cc\r
68 @@ -285,6 +285,7 @@ notmuch_threads_t *\r
69  notmuch_query_search_threads (notmuch_query_t *query)\r
70  {\r
71      notmuch_threads_t *threads;\r
72 +    notmuch_message_t *message;\r
73  \r
74      threads = talloc (query, notmuch_threads_t);\r
75      if (threads == NULL)\r
76 @@ -296,7 +297,10 @@ notmuch_query_search_threads (notmuch_query_t *query)\r
77  \r
78      threads->messages = notmuch_query_search_messages (query);\r
79  \r
80 -    threads->thread_id = NULL;\r
81 +    message = notmuch_messages_get (threads->messages);\r
82 +    threads->thread_id = notmuch_message_get_thread_id (message);\r
83 +    g_hash_table_insert (threads->threads,\r
84 +                         xstrdup (threads->thread_id), NULL);\r
85  \r
86      talloc_set_destructor (threads, _notmuch_threads_destructor);\r
87  \r
88 @@ -312,10 +316,25 @@ notmuch_query_destroy (notmuch_query_t *query)\r
89  notmuch_bool_t\r
90  notmuch_threads_valid (notmuch_threads_t *threads)\r
91  {\r
92 -    notmuch_message_t *message;\r
93 +    return (threads->thread_id != NULL);\r
94 +}\r
95  \r
96 -    if (threads->thread_id)\r
97 -       return TRUE;\r
98 +notmuch_thread_t *\r
99 +notmuch_threads_get (notmuch_threads_t *threads)\r
100 +{\r
101 +    if (! notmuch_threads_valid (threads))\r
102 +       return NULL;\r
103 +\r
104 +    return _notmuch_thread_create (threads->query,\r
105 +                                  threads->query->notmuch,\r
106 +                                  threads->thread_id,\r
107 +                                  threads->query->query_string);\r
108 +}\r
109 +\r
110 +void\r
111 +notmuch_threads_move_to_next (notmuch_threads_t *threads)\r
112 +{\r
113 +    notmuch_message_t *message;\r
114  \r
115      while (notmuch_messages_valid (threads->messages))\r
116      {\r
117 @@ -330,33 +349,15 @@ notmuch_threads_valid (notmuch_threads_t *threads)\r
118             g_hash_table_insert (threads->threads,\r
119                                  xstrdup (threads->thread_id), NULL);\r
120             notmuch_messages_move_to_next (threads->messages);\r
121 -           return TRUE;\r
122 +           return;\r
123         }\r
124  \r
125         notmuch_messages_move_to_next (threads->messages);\r
126      }\r
127  \r
128      threads->thread_id = NULL;\r
129 -    return FALSE;\r
130 -}\r
131 -\r
132 -notmuch_thread_t *\r
133 -notmuch_threads_get (notmuch_threads_t *threads)\r
134 -{\r
135 -    if (! notmuch_threads_valid (threads))\r
136 -       return NULL;\r
137 -\r
138 -    return _notmuch_thread_create (threads->query,\r
139 -                                  threads->query->notmuch,\r
140 -                                  threads->thread_id,\r
141 -                                  threads->query->query_string);\r
142  }\r
143  \r
144 -void\r
145 -notmuch_threads_move_to_next (notmuch_threads_t *threads)\r
146 -{\r
147 -    threads->thread_id = NULL;\r
148 -}\r
149  \r
150  void\r
151  notmuch_threads_destroy (notmuch_threads_t *threads)\r
152 -- \r
153 1.7.0\r
154 \r