unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: Jameson Graef Rollins <jrollins@finestructure.net>
Cc: Notmuch Mail <notmuch@notmuchmail.org>
Subject: Re: [PATCH 02/11] lib: use new addresses structure for thread authors
Date: Sat, 8 Sep 2012 13:24:23 -0400	[thread overview]
Message-ID: <20120908172423.GA22117@mit.edu> (raw)
In-Reply-To: <1345427570-26518-3-git-send-email-jrollins@finestructure.net>

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.

  parent reply	other threads:[~2012-09-08 17:24 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-20  1:52 [PATCH 00/11] add recipients to search output Jameson Graef Rollins
2012-08-20  1:52 ` [PATCH 01/11] lib: new thread addresses structure Jameson Graef Rollins
2012-08-20  1:52   ` [PATCH 02/11] lib: use new addresses structure for thread authors Jameson Graef Rollins
2012-08-20  1:52     ` [PATCH 03/11] lib: give _thread_cleanup_author a more generic name Jameson Graef Rollins
2012-08-20  1:52       ` [PATCH 04/11] lib: remove no longer needed author-specific thread functions Jameson Graef Rollins
2012-08-20  1:52         ` [PATCH 05/11] lib: add ability to store recipients in message structure Jameson Graef Rollins
2012-08-20  1:52           ` [PATCH 06/11] lib: store thread recipients in thread structure Jameson Graef Rollins
2012-08-20  1:52             ` [PATCH 07/11] test: search recipient output Jameson Graef Rollins
2012-08-20  1:52               ` [PATCH 08/11] cli: add thread recipients to search output Jameson Graef Rollins
2012-08-20  1:52                 ` [PATCH 09/11] emacs: add ability to show recipients instead of author in search Jameson Graef Rollins
2012-08-20  1:52                   ` [PATCH 10/11] emacs: add function to toggle showing authors/recipients " Jameson Graef Rollins
2012-08-20  1:52                     ` [PATCH 11/11] lib: add recipients to database Jameson Graef Rollins
2012-08-31 21:34                       ` Michal Sojka
2012-08-31 21:00                 ` [PATCH 08/11] cli: add thread recipients to search output Michal Sojka
2012-08-31 20:44             ` [PATCH 06/11] lib: store thread recipients in thread structure Michal Sojka
2012-09-02  7:52             ` Mark Walters
2012-09-08 17:25             ` Austin Clements
2012-08-31 20:19           ` [PATCH 05/11] lib: add ability to store recipients in message structure Michal Sojka
2012-09-08 17:24           ` Austin Clements
2012-09-08 17:25       ` [PATCH 03/11] lib: give _thread_cleanup_author a more generic name Austin Clements
2012-09-08 17:24     ` Austin Clements [this message]
2012-08-30 15:38   ` [PATCH 01/11] lib: new thread addresses structure Michal Sojka
2012-08-30 16:33     ` Jameson Graef Rollins
2012-09-08 17:24   ` Austin Clements
2012-08-22 20:43 ` [PATCH 00/11] add recipients to search output Jameson Graef Rollins
2012-08-23  7:21 ` Tomi Ollila
2012-09-08 17:23 ` Austin Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120908172423.GA22117@mit.edu \
    --to=amdragon@mit.edu \
    --cc=jrollins@finestructure.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).