[notmuch] [PATCH 1/2] Move the logic of threads iterator out of 'valid'
authorRuben Pollan <meskio@sindominio.net>
Sun, 21 Mar 2010 21:32:32 +0000 (22:32 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:25 +0000 (09:36 -0800)
0d/19b02d94dbf68db6cdce43322c6cde530f6084 [new file with mode: 0644]

diff --git a/0d/19b02d94dbf68db6cdce43322c6cde530f6084 b/0d/19b02d94dbf68db6cdce43322c6cde530f6084
new file mode 100644 (file)
index 0000000..545b280
--- /dev/null
@@ -0,0 +1,160 @@
+Return-Path: <meskio@sindominio.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 olra.theworths.org (Postfix) with ESMTP id 9ACAF4196F2\r
+       for <notmuch@notmuchmail.org>; Sun, 21 Mar 2010 14:30:20 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.9\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9] autolearn=ham\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id uGMrN-Ivr3s6 for <notmuch@notmuchmail.org>;\r
+       Sun, 21 Mar 2010 14:30:19 -0700 (PDT)\r
+Received: from flatline.sindominio.net (flatline.sindominio.net [82.144.4.26])\r
+       by olra.theworths.org (Postfix) with ESMTP id EE37B431FC1\r
+       for <notmuch@notmuchmail.org>; Sun, 21 Mar 2010 14:30:12 -0700 (PDT)\r
+Received: from localhost (localhost.localdomain [127.0.0.1])\r
+       by flatline.sindominio.net (Postfix) with ESMTP id 1E966348093;\r
+       Sun, 21 Mar 2010 22:30:12 +0100 (CET)\r
+X-Virus-Scanned: Debian amavisd-new at sindominio.net\r
+Received: from flatline.sindominio.net ([127.0.0.1])\r
+       by localhost (flatline.sindominio.net [127.0.0.1]) (amavisd-new,\r
+       port 10024)\r
+       with ESMTP id 05IfKiPJPeWe; Sun, 21 Mar 2010 22:29:54 +0100 (CET)\r
+Received: from blackspot (heal.cauterized.net [89.140.131.167])\r
+       by flatline.sindominio.net (Postfix) with ESMTPA id EC32C348046;\r
+       Sun, 21 Mar 2010 22:29:06 +0100 (CET)\r
+Received: by blackspot (Postfix, from userid 1000)\r
+       id 7093C8BDFC; Sun, 21 Mar 2010 22:32:39 +0100 (CET)\r
+From: Ruben Pollan <meskio@sindominio.net>\r
+To: notmuch@notmuchmail.org\r
+Date: Sun, 21 Mar 2010 22:32:32 +0100\r
+Message-Id: <1269207153-3687-2-git-send-email-meskio@sindominio.net>\r
+X-Mailer: git-send-email 1.7.0\r
+In-Reply-To: <1269080605-5617-1-git-send-email-meskio@sindominio.net>\r
+References: <1269080605-5617-1-git-send-email-meskio@sindominio.net>\r
+Subject: [notmuch] [PATCH 1/2] Move the logic of threads iterator out of\r
+       'valid'\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\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: Sun, 21 Mar 2010 21:30:20 -0000\r
+\r
+The logic of notmuch_threads_move_to_next iterator was on\r
+notmuch_threads_valid function. Now notmuch_threads_valid just check if\r
+the iterator is valid and is notmuch_threads_move_to_next wich actually\r
+update the iterator.\r
+---\r
+ lib/query.cc |   54 ++++++++++++++++++++++++++++++------------------------\r
+ 1 files changed, 30 insertions(+), 24 deletions(-)\r
+\r
+diff --git a/lib/query.cc b/lib/query.cc\r
+index 9266d35..514a156 100644\r
+--- a/lib/query.cc\r
++++ b/lib/query.cc\r
+@@ -233,6 +233,7 @@ notmuch_threads_t *\r
+ notmuch_query_search_threads (notmuch_query_t *query)\r
+ {\r
+     notmuch_threads_t *threads;\r
++    notmuch_message_t *message;\r
\r
+     threads = talloc (query, notmuch_threads_t);\r
+     if (threads == NULL)\r
+@@ -243,8 +244,17 @@ notmuch_query_search_threads (notmuch_query_t *query)\r
+                                             free, NULL);\r
\r
+     threads->messages = notmuch_query_search_messages (query);\r
++    if (!notmuch_messages_valid (threads->messages))\r
++    {\r
++        threads->thread_id = NULL;\r
++        return threads;\r
++    }\r
\r
+-    threads->thread_id = NULL;\r
++    message = notmuch_messages_get (threads->messages);\r
++    threads->thread_id = notmuch_message_get_thread_id (message);\r
++    g_hash_table_insert (threads->threads,\r
++                         xstrdup (threads->thread_id),\r
++                         NULL);\r
\r
+     talloc_set_destructor (threads, _notmuch_threads_destructor);\r
\r
+@@ -260,10 +270,25 @@ notmuch_query_destroy (notmuch_query_t *query)\r
+ notmuch_bool_t\r
+ notmuch_threads_valid (notmuch_threads_t *threads)\r
+ {\r
+-    notmuch_message_t *message;\r
++    return (threads->thread_id != NULL);\r
++}\r
++\r
++notmuch_thread_t *\r
++notmuch_threads_get (notmuch_threads_t *threads)\r
++{\r
++    if (! notmuch_threads_valid (threads))\r
++      return NULL;\r
++\r
++    return _notmuch_thread_create (threads->query,\r
++                                 threads->query->notmuch,\r
++                                 threads->thread_id,\r
++                                 threads->query->query_string);\r
++}\r
\r
+-    if (threads->thread_id)\r
+-      return TRUE;\r
++void\r
++notmuch_threads_move_to_next (notmuch_threads_t *threads)\r
++{\r
++    notmuch_message_t *message;\r
\r
+     while (notmuch_messages_valid (threads->messages))\r
+     {\r
+@@ -278,32 +303,13 @@ notmuch_threads_valid (notmuch_threads_t *threads)\r
+           g_hash_table_insert (threads->threads,\r
+                                xstrdup (threads->thread_id), NULL);\r
+           notmuch_messages_move_to_next (threads->messages);\r
+-          return TRUE;\r
++          return;\r
+       }\r
\r
+       notmuch_messages_move_to_next (threads->messages);\r
+     }\r
\r
+     threads->thread_id = NULL;\r
+-    return FALSE;\r
+-}\r
+-\r
+-notmuch_thread_t *\r
+-notmuch_threads_get (notmuch_threads_t *threads)\r
+-{\r
+-    if (! notmuch_threads_valid (threads))\r
+-      return NULL;\r
+-\r
+-    return _notmuch_thread_create (threads->query,\r
+-                                 threads->query->notmuch,\r
+-                                 threads->thread_id,\r
+-                                 threads->query->query_string);\r
+-}\r
+-\r
+-void\r
+-notmuch_threads_move_to_next (notmuch_threads_t *threads)\r
+-{\r
+-    threads->thread_id = NULL;\r
+ }\r
\r
+ void\r
+-- \r
+1.7.0\r
+\r