[PATCH 02/11] lib: use new addresses structure for thread authors
authorJameson Graef Rollins <jrollins@finestructure.net>
Mon, 20 Aug 2012 01:52:41 +0000 (18:52 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:49:08 +0000 (09:49 -0800)
a4/91911c767afb9eb2f1a2dd3d37ad42bac78142 [new file with mode: 0644]

diff --git a/a4/91911c767afb9eb2f1a2dd3d37ad42bac78142 b/a4/91911c767afb9eb2f1a2dd3d37ad42bac78142
new file mode 100644 (file)
index 0000000..11cb1a9
--- /dev/null
@@ -0,0 +1,159 @@
+Return-Path: <jrollins@finestructure.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 587C2431FBD\r
+       for <notmuch@notmuchmail.org>; Sun, 19 Aug 2012 18:53:16 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\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 ecyA0FAXQmej for <notmuch@notmuchmail.org>;\r
+       Sun, 19 Aug 2012 18:53:14 -0700 (PDT)\r
+Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
+       [131.215.239.19])\r
+       by olra.theworths.org (Postfix) with ESMTP id 9850D431FC7\r
+       for <notmuch@notmuchmail.org>; Sun, 19 Aug 2012 18:53:08 -0700 (PDT)\r
+Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
+       by fire-doxen-postvirus (Postfix) with ESMTP id 4032A2E50D7E\r
+       for <notmuch@notmuchmail.org>; Sun, 19 Aug 2012 18:53:06 -0700 (PDT)\r
+X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new\r
+Received: from finestructure.net (unknown [76.89.192.57])\r
+       (Authenticated sender: jrollins)\r
+       by fire-doxen-submit (Postfix) with ESMTP id 50083328015\r
+       for <notmuch@notmuchmail.org>; Sun, 19 Aug 2012 18:53:04 -0700 (PDT)\r
+Received: by finestructure.net (Postfix, from userid 1000)\r
+       id CB4FA868; Sun, 19 Aug 2012 18:53:03 -0700 (PDT)\r
+From: Jameson Graef Rollins <jrollins@finestructure.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH 02/11] lib: use new addresses structure for thread authors\r
+Date: Sun, 19 Aug 2012 18:52:41 -0700\r
+Message-Id: <1345427570-26518-3-git-send-email-jrollins@finestructure.net>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1345427570-26518-2-git-send-email-jrollins@finestructure.net>\r
+References: <1345427570-26518-1-git-send-email-jrollins@finestructure.net>\r
+       <1345427570-26518-2-git-send-email-jrollins@finestructure.net>\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: Mon, 20 Aug 2012 01:53:16 -0000\r
+\r
+Now that we have the infrastructure in place, we modify the thread\r
+object and associated functions to use the new addresses structure for\r
+storing thread authors.\r
+---\r
+ lib/thread.cc |   41 +++++++++++------------------------------\r
+ 1 file changed, 11 insertions(+), 30 deletions(-)\r
+\r
+diff --git a/lib/thread.cc b/lib/thread.cc\r
+index 7af9eeb..9e0e5cb 100644\r
+--- a/lib/thread.cc\r
++++ b/lib/thread.cc\r
+@@ -36,11 +36,7 @@ struct visible _notmuch_thread {\r
+     notmuch_database_t *notmuch;\r
+     char *thread_id;\r
+     char *subject;\r
+-    GHashTable *authors_hash;\r
+-    GPtrArray *authors_array;\r
+-    GHashTable *matched_authors_hash;\r
+-    GPtrArray *matched_authors_array;\r
+-    char *authors;\r
++    notmuch_thread_addresses_t *authors;\r
+     GHashTable *tags;\r
+ \r
+     notmuch_message_list_t *message_list;\r
+@@ -66,21 +62,9 @@ _notmuch_thread_addresses_destructor (notmuch_thread_addresses_t *addresses)\r
+ static int\r
+ _notmuch_thread_destructor (notmuch_thread_t *thread)\r
+ {\r
+-    g_hash_table_unref (thread->authors_hash);\r
+-    g_hash_table_unref (thread->matched_authors_hash);\r
++    _notmuch_thread_addresses_destructor (thread->authors);\r
+     g_hash_table_unref (thread->tags);\r
+     g_hash_table_unref (thread->message_hash);\r
+-\r
+-    if (thread->authors_array) {\r
+-      g_ptr_array_free (thread->authors_array, TRUE);\r
+-      thread->authors_array = NULL;\r
+-    }\r
+-\r
+-    if (thread->matched_authors_array) {\r
+-      g_ptr_array_free (thread->matched_authors_array, TRUE);\r
+-      thread->matched_authors_array = NULL;\r
+-    }\r
+-\r
+     return 0;\r
+ }\r
+ \r
+@@ -341,7 +325,7 @@ _thread_add_message (notmuch_thread_t *thread,\r
+               author = internet_address_mailbox_get_addr (mailbox);\r
+           }\r
+           clean_author = _thread_cleanup_author (thread, author, from);\r
+-          _thread_add_author (thread, clean_author);\r
++          _thread_add_address (thread->authors, clean_author, FALSE);\r
+           notmuch_message_set_author (message, clean_author);\r
+       }\r
+       g_object_unref (G_OBJECT (list));\r
+@@ -436,7 +420,7 @@ _thread_add_matched_message (notmuch_thread_t *thread,\r
+                                 NOTMUCH_MESSAGE_FLAG_MATCH, 1);\r
+     }\r
+ \r
+-    _thread_add_matched_author (thread, notmuch_message_get_author (hashed_message));\r
++    _thread_add_address (thread->authors, notmuch_message_get_author (hashed_message), TRUE);\r
+ }\r
+ \r
+ static void\r
+@@ -555,14 +539,11 @@ _notmuch_thread_create (void *ctx,\r
+     thread->notmuch = notmuch;\r
+     thread->thread_id = talloc_strdup (thread, thread_id);\r
+     thread->subject = NULL;\r
+-    thread->authors_hash = g_hash_table_new_full (g_str_hash, g_str_equal,\r
+-                                                NULL, NULL);\r
+-    thread->authors_array = g_ptr_array_new ();\r
+-    thread->matched_authors_hash = g_hash_table_new_full (g_str_hash,\r
+-                                                        g_str_equal,\r
+-                                                        NULL, NULL);\r
+-    thread->matched_authors_array = g_ptr_array_new ();\r
+-    thread->authors = NULL;\r
++\r
++    thread->authors = _thread_addresses_init (thread);\r
++    if (unlikely (thread->authors == NULL))\r
++      return NULL;\r
++\r
+     thread->tags = g_hash_table_new_full (g_str_hash, g_str_equal,\r
+                                         free, NULL);\r
+ \r
+@@ -607,7 +588,7 @@ _notmuch_thread_create (void *ctx,\r
+ \r
+     notmuch_query_destroy (thread_id_query);\r
+ \r
+-    _resolve_thread_authors_string (thread);\r
++    _resolve_thread_addresses_string (thread->authors);\r
+ \r
+     _resolve_thread_relationships (thread);\r
+ \r
+@@ -641,7 +622,7 @@ notmuch_thread_get_matched_messages (notmuch_thread_t *thread)\r
+ const char *\r
+ notmuch_thread_get_authors (notmuch_thread_t *thread)\r
+ {\r
+-    return thread->authors;\r
++    return thread->authors->string;\r
+ }\r
+ \r
+ const char *\r
+-- \r
+1.7.10.4\r
+\r