From: Jameson Graef Rollins <jrollins@finestructure.net>
To: Michal Sojka <sojkam1@fel.cvut.cz>,
Notmuch Mail <notmuch@notmuchmail.org>
Subject: Re: [PATCH 01/11] lib: new thread addresses structure
Date: Thu, 30 Aug 2012 09:33:56 -0700 [thread overview]
Message-ID: <874nnkpcej.fsf@servo.finestructure.net> (raw)
In-Reply-To: <87y5kw4cfo.fsf@steelpick.2x.cz>
[-- Attachment #1: Type: text/plain, Size: 2689 bytes --]
Hey, Michal. Thanks for the review.
On Thu, Aug 30 2012, Michal Sojka <sojkam1@fel.cvut.cz> wrote:
>> +/* Construct an addresses string from matched and unmatched addresses
>> + * in notmuch_thread_addresses_t. The string contains matched
>> + * addresses first, then non-matched addresses (with the two groups
>> + * separated by '|'). Within each group, addresses are listed in date
>> + * order. */
>
> I'd say the the addresses are listed in the order in which they have
> been added, which might or might not be the date order.
I actually did not write the _resolve_thread_addresses_string function.
I left the logic and behavior unchanged, and just modified to use the
new addresses structure. If we think the logic should be changed, maybe
we should do that in a separate patch.
>> +static void
>> +_resolve_thread_addresses_string (notmuch_thread_addresses_t *addresses)
>> +{
>> + unsigned int i;
>> + char *address;
>> + int first_non_matched_address = 1;
>> +
>> + /* First, list all matched addressses in date order. */
>> + for (i = 0; i < addresses->matched_array->len; i++) {
>> + address = (char *) g_ptr_array_index (addresses->matched_array, i);
>> + if (addresses->string)
>> + addresses->string = talloc_asprintf (addresses, "%s, %s",
>> + addresses->string,
>> + address);
>> + else
>> + addresses->string = address;
>> + }
>> +
>> + /* Next, append any non-matched addresses that haven't already appeared. */
>> + for (i = 0; i < addresses->unmatched_array->len; i++) {
>> + address = (char *) g_ptr_array_index (addresses->unmatched_array, i);
>> + if (g_hash_table_lookup_extended (addresses->matched_hash,
>> + address, NULL, NULL))
>> + continue;
>> + if (first_non_matched_address) {
>> + addresses->string = talloc_asprintf (addresses, "%s| %s",
>> + addresses->string,
>> + address);
>> + } else {
>> + addresses->string = talloc_asprintf (addresses, "%s, %s",
>> + addresses->string,
>> + address);
>> + }
>
> Simpler would be:
>
> addresses->string = talloc_asprintf (addresses, "%s%c %s",
> addresses->string,
> first_non_matched_address ? '|' : ','
> address);
>
> Also, you might want to talloc_free the old address->string to not waste
> memory in the case of long lived notmuch_thread_addresses_t object. Or
> better use talloc_asprintf_append() function, which hopefully implements
> freeing internally.
This looks like a nice simplification, but see comment above.
I'll look into including these changes in the next version of the
series.
jamie.
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
next prev parent reply other threads:[~2012-08-30 16:34 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 ` [PATCH 02/11] lib: use new addresses structure for thread authors Austin Clements
2012-08-30 15:38 ` [PATCH 01/11] lib: new thread addresses structure Michal Sojka
2012-08-30 16:33 ` Jameson Graef Rollins [this message]
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=874nnkpcej.fsf@servo.finestructure.net \
--to=jrollins@finestructure.net \
--cc=notmuch@notmuchmail.org \
--cc=sojkam1@fel.cvut.cz \
/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).