Re: [PATCH 02/11] lib: use new addresses structure for thread authors
authorAustin Clements <amdragon@MIT.EDU>
Sat, 8 Sep 2012 17:24:23 +0000 (13:24 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:49:26 +0000 (09:49 -0800)
e7/2c3fc923ce76e406e061432ec544ad4c825209 [new file with mode: 0644]

diff --git a/e7/2c3fc923ce76e406e061432ec544ad4c825209 b/e7/2c3fc923ce76e406e061432ec544ad4c825209
new file mode 100644 (file)
index 0000000..c64924c
--- /dev/null
@@ -0,0 +1,201 @@
+Return-Path: <amdragon@mit.edu>\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 18317431FAF\r
+       for <notmuch@notmuchmail.org>; Sat,  8 Sep 2012 10:24:27 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 FNO36cWvF36A for <notmuch@notmuchmail.org>;\r
+       Sat,  8 Sep 2012 10:24:26 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
+       [18.9.25.15])\r
+       by olra.theworths.org (Postfix) with ESMTP id 0EF40431FBD\r
+       for <notmuch@notmuchmail.org>; Sat,  8 Sep 2012 10:24:25 -0700 (PDT)\r
+X-AuditID: 1209190f-b7f706d0000008d5-d8-504b7f492385\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+       by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id E8.A7.02261.94F7B405; Sat,  8 Sep 2012 13:24:25 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q88HOOEa020240; \r
+       Sat, 8 Sep 2012 13:24:25 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q88HONeR026350\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Sat, 8 Sep 2012 13:24:24 -0400 (EDT)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1TAOlb-00061d-7p; Sat, 08 Sep 2012 13:24:23 -0400\r
+Date: Sat, 8 Sep 2012 13:24:23 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Jameson Graef Rollins <jrollins@finestructure.net>\r
+Subject: Re: [PATCH 02/11] lib: use new addresses structure for thread authors\r
+Message-ID: <20120908172423.GA22117@mit.edu>\r
+References: <1345427570-26518-1-git-send-email-jrollins@finestructure.net>\r
+       <1345427570-26518-2-git-send-email-jrollins@finestructure.net>\r
+       <1345427570-26518-3-git-send-email-jrollins@finestructure.net>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <1345427570-26518-3-git-send-email-jrollins@finestructure.net>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IRYrdT1/Ws9w4waHqmbLFnn5fF9ZszmR2Y\r
+       PO6e5vJ4tuoWcwBTFJdNSmpOZllqkb5dAlfG1ZMdzAXrlCom7TrI1MD4WKqLkZNDQsBE4u6C\r
+       l6wQtpjEhXvr2boYuTiEBPYxSuy7sZEFwlnPKPFl5h4o5wSTxKe+3awQzhJGiebG2Swg/SwC\r
+       KhKnv99lA7HZBDQktu1fzghiiwiYSfR8+QNmMwtoSWzd+AHMFhbwk/j+eRY7iM0roCMx6/Ic\r
+       ZoihZxglmvavgkoISpyc+YQFpvnGv5dMXYwcQLa0xPJ/HCBhTgFviWu3PoCViALdMOXkNrYJ\r
+       jEKzkHTPQtI9C6F7ASPzKkbZlNwq3dzEzJzi1GTd4uTEvLzUIl0TvdzMEr3UlNJNjKCw5pTk\r
+       38H47aDSIUYBDkYlHt4Ncl4BQqyJZcWVuYcYJTmYlER5d9d4BwjxJeWnVGYkFmfEF5XmpBYf\r
+       YpTgYFYS4b2eDpTjTUmsrEotyodJSXOwKInzXk256S8kkJ5YkpqdmlqQWgSTleHgUJLgta0D\r
+       ahQsSk1PrUjLzClBSDNxcIIM5wEabgxSw1tckJhbnJkOkT/FqCglzusNcpEASCKjNA+uF5Z2\r
+       XjGKA70iDLGCB5iy4LpfAQ1mAhos8swDZHBJIkJKqoHRvJPnRPqmZepFlXeb98d/3hofWxZ2\r
+       syrvTfE19VmzxbZ0u9zJDDi8mI1z268olb+NGkZTLINXijl/O3MoRENiuYejjsZ0Mdl1R/X3\r
+       GYf0H4md+vO36Te1/vp3JhOTZb9xBZgqXj81/dvT3ZUZrQGGQbHvNjA7fA/dLebxwUg/KNYl\r
+       /eOuSyVKLMUZiYZazEXFiQBk9+zbFgMAAA==\r
+Cc: Notmuch Mail <notmuch@notmuchmail.org>\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: Sat, 08 Sep 2012 17:24:27 -0000\r
+\r
+Quoth Jameson Graef Rollins on Aug 19 at  6:52 pm:\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
+\r
+This is the explicit call I mentioned in my talloc destructor comment\r
+on patch 1.\r
+\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
+If you make my suggested change to the\r
+_resolve_thread_addresses_string API, this call would simply go\r
+away...\r
+\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
+... and this would be return _thread_addresses_to_string (or\r
+whatever).\r
+\r
+>  }\r
+>  \r
+>  const char *\r
+\r
+-- \r
+Austin Clements                                      MIT/'06/PhD/CSAIL\r
+amdragon@mit.edu                           http://web.mit.edu/amdragon\r
+       Somewhere in the dream we call reality you will find me,\r
+              searching for the reality we call dreams.\r