From: Austin Clements Date: Sat, 8 Sep 2012 17:24:23 +0000 (+2000) Subject: Re: [PATCH 02/11] lib: use new addresses structure for thread authors X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=490a59ece7c4e8d3977251f34c29bc3f45675715;p=notmuch-archives.git Re: [PATCH 02/11] lib: use new addresses structure for thread authors --- diff --git a/e7/2c3fc923ce76e406e061432ec544ad4c825209 b/e7/2c3fc923ce76e406e061432ec544ad4c825209 new file mode 100644 index 000000000..c64924c9f --- /dev/null +++ b/e7/2c3fc923ce76e406e061432ec544ad4c825209 @@ -0,0 +1,201 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 18317431FAF + for ; Sat, 8 Sep 2012 10:24:27 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id FNO36cWvF36A for ; + Sat, 8 Sep 2012 10:24:26 -0700 (PDT) +Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU + [18.9.25.15]) + by olra.theworths.org (Postfix) with ESMTP id 0EF40431FBD + for ; Sat, 8 Sep 2012 10:24:25 -0700 (PDT) +X-AuditID: 1209190f-b7f706d0000008d5-d8-504b7f492385 +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP + id E8.A7.02261.94F7B405; Sat, 8 Sep 2012 13:24:25 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q88HOOEa020240; + Sat, 8 Sep 2012 13:24:25 -0400 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q88HONeR026350 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Sat, 8 Sep 2012 13:24:24 -0400 (EDT) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1TAOlb-00061d-7p; Sat, 08 Sep 2012 13:24:23 -0400 +Date: Sat, 8 Sep 2012 13:24:23 -0400 +From: Austin Clements +To: Jameson Graef Rollins +Subject: Re: [PATCH 02/11] lib: use new addresses structure for thread authors +Message-ID: <20120908172423.GA22117@mit.edu> +References: <1345427570-26518-1-git-send-email-jrollins@finestructure.net> + <1345427570-26518-2-git-send-email-jrollins@finestructure.net> + <1345427570-26518-3-git-send-email-jrollins@finestructure.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1345427570-26518-3-git-send-email-jrollins@finestructure.net> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IRYrdT1/Ws9w4waHqmbLFnn5fF9ZszmR2Y + PO6e5vJ4tuoWcwBTFJdNSmpOZllqkb5dAlfG1ZMdzAXrlCom7TrI1MD4WKqLkZNDQsBE4u6C + l6wQtpjEhXvr2boYuTiEBPYxSuy7sZEFwlnPKPFl5h4o5wSTxKe+3awQzhJGiebG2Swg/SwC + KhKnv99lA7HZBDQktu1fzghiiwiYSfR8+QNmMwtoSWzd+AHMFhbwk/j+eRY7iM0roCMx6/Ic + ZoihZxglmvavgkoISpyc+YQFpvnGv5dMXYwcQLa0xPJ/HCBhTgFviWu3PoCViALdMOXkNrYJ + jEKzkHTPQtI9C6F7ASPzKkbZlNwq3dzEzJzi1GTd4uTEvLzUIl0TvdzMEr3UlNJNjKCw5pTk + 38H47aDSIUYBDkYlHt4Ncl4BQqyJZcWVuYcYJTmYlER5d9d4BwjxJeWnVGYkFmfEF5XmpBYf + YpTgYFYS4b2eDpTjTUmsrEotyodJSXOwKInzXk256S8kkJ5YkpqdmlqQWgSTleHgUJLgta0D + ahQsSk1PrUjLzClBSDNxcIIM5wEabgxSw1tckJhbnJkOkT/FqCglzusNcpEASCKjNA+uF5Z2 + XjGKA70iDLGCB5iy4LpfAQ1mAhos8swDZHBJIkJKqoHRvJPnRPqmZepFlXeb98d/3hofWxZ2 + syrvTfE19VmzxbZ0u9zJDDi8mI1z268olb+NGkZTLINXijl/O3MoRENiuYejjsZ0Mdl1R/X3 + GYf0H4md+vO36Te1/vp3JhOTZb9xBZgqXj81/dvT3ZUZrQGGQbHvNjA7fA/dLebxwUg/KNYl + /eOuSyVKLMUZiYZazEXFiQBk9+zbFgMAAA== +Cc: Notmuch Mail +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 08 Sep 2012 17:24:27 -0000 + +Quoth Jameson Graef Rollins on Aug 19 at 6:52 pm: +> Now that we have the infrastructure in place, we modify the thread +> object and associated functions to use the new addresses structure for +> storing thread authors. +> --- +> lib/thread.cc | 41 +++++++++++------------------------------ +> 1 file changed, 11 insertions(+), 30 deletions(-) +> +> diff --git a/lib/thread.cc b/lib/thread.cc +> index 7af9eeb..9e0e5cb 100644 +> --- a/lib/thread.cc +> +++ b/lib/thread.cc +> @@ -36,11 +36,7 @@ struct visible _notmuch_thread { +> notmuch_database_t *notmuch; +> char *thread_id; +> char *subject; +> - GHashTable *authors_hash; +> - GPtrArray *authors_array; +> - GHashTable *matched_authors_hash; +> - GPtrArray *matched_authors_array; +> - char *authors; +> + notmuch_thread_addresses_t *authors; +> GHashTable *tags; +> +> notmuch_message_list_t *message_list; +> @@ -66,21 +62,9 @@ _notmuch_thread_addresses_destructor (notmuch_thread_addresses_t *addresses) +> static int +> _notmuch_thread_destructor (notmuch_thread_t *thread) +> { +> - g_hash_table_unref (thread->authors_hash); +> - g_hash_table_unref (thread->matched_authors_hash); +> + _notmuch_thread_addresses_destructor (thread->authors); + +This is the explicit call I mentioned in my talloc destructor comment +on patch 1. + +> g_hash_table_unref (thread->tags); +> g_hash_table_unref (thread->message_hash); +> - +> - if (thread->authors_array) { +> - g_ptr_array_free (thread->authors_array, TRUE); +> - thread->authors_array = NULL; +> - } +> - +> - if (thread->matched_authors_array) { +> - g_ptr_array_free (thread->matched_authors_array, TRUE); +> - thread->matched_authors_array = NULL; +> - } +> - +> return 0; +> } +> +> @@ -341,7 +325,7 @@ _thread_add_message (notmuch_thread_t *thread, +> author = internet_address_mailbox_get_addr (mailbox); +> } +> clean_author = _thread_cleanup_author (thread, author, from); +> - _thread_add_author (thread, clean_author); +> + _thread_add_address (thread->authors, clean_author, FALSE); +> notmuch_message_set_author (message, clean_author); +> } +> g_object_unref (G_OBJECT (list)); +> @@ -436,7 +420,7 @@ _thread_add_matched_message (notmuch_thread_t *thread, +> NOTMUCH_MESSAGE_FLAG_MATCH, 1); +> } +> +> - _thread_add_matched_author (thread, notmuch_message_get_author (hashed_message)); +> + _thread_add_address (thread->authors, notmuch_message_get_author (hashed_message), TRUE); +> } +> +> static void +> @@ -555,14 +539,11 @@ _notmuch_thread_create (void *ctx, +> thread->notmuch = notmuch; +> thread->thread_id = talloc_strdup (thread, thread_id); +> thread->subject = NULL; +> - thread->authors_hash = g_hash_table_new_full (g_str_hash, g_str_equal, +> - NULL, NULL); +> - thread->authors_array = g_ptr_array_new (); +> - thread->matched_authors_hash = g_hash_table_new_full (g_str_hash, +> - g_str_equal, +> - NULL, NULL); +> - thread->matched_authors_array = g_ptr_array_new (); +> - thread->authors = NULL; +> + +> + thread->authors = _thread_addresses_init (thread); +> + if (unlikely (thread->authors == NULL)) +> + return NULL; +> + +> thread->tags = g_hash_table_new_full (g_str_hash, g_str_equal, +> free, NULL); +> +> @@ -607,7 +588,7 @@ _notmuch_thread_create (void *ctx, +> +> notmuch_query_destroy (thread_id_query); +> +> - _resolve_thread_authors_string (thread); +> + _resolve_thread_addresses_string (thread->authors); + +If you make my suggested change to the +_resolve_thread_addresses_string API, this call would simply go +away... + +> +> _resolve_thread_relationships (thread); +> +> @@ -641,7 +622,7 @@ notmuch_thread_get_matched_messages (notmuch_thread_t *thread) +> const char * +> notmuch_thread_get_authors (notmuch_thread_t *thread) +> { +> - return thread->authors; +> + return thread->authors->string; + +... and this would be return _thread_addresses_to_string (or +whatever). + +> } +> +> const char * + +-- +Austin Clements MIT/'06/PhD/CSAIL +amdragon@mit.edu http://web.mit.edu/amdragon + Somewhere in the dream we call reality you will find me, + searching for the reality we call dreams.