Re: [PATCH 01/11] lib: new thread addresses structure
authorJameson Graef Rollins <jrollins@finestructure.net>
Thu, 30 Aug 2012 16:33:56 +0000 (09:33 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:49:14 +0000 (09:49 -0800)
c2/a6c136302f4213829ddea35dfba1e607d48698 [new file with mode: 0644]

diff --git a/c2/a6c136302f4213829ddea35dfba1e607d48698 b/c2/a6c136302f4213829ddea35dfba1e607d48698
new file mode 100644 (file)
index 0000000..4febe04
--- /dev/null
@@ -0,0 +1,151 @@
+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 D7309431FBC\r
+       for <notmuch@notmuchmail.org>; Thu, 30 Aug 2012 09:34:11 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.29\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.29 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3, T_MIME_NO_TEXT=0.01] 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 hiYKKLFe7Q+q for <notmuch@notmuchmail.org>;\r
+       Thu, 30 Aug 2012 09:34:10 -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 B2D67431FAE\r
+       for <notmuch@notmuchmail.org>; Thu, 30 Aug 2012 09:34:10 -0700 (PDT)\r
+Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
+       by fire-doxen-postvirus (Postfix) with ESMTP id DB3FA328060;\r
+       Thu, 30 Aug 2012 09:34:01 -0700 (PDT)\r
+X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new\r
+Received: from finestructure.net (m9.ligo.caltech.edu [131.215.115.109])\r
+       (Authenticated sender: jrollins)\r
+       by fire-doxen-submit (Postfix) with ESMTP id 04B432E50B61;\r
+       Thu, 30 Aug 2012 09:33:58 -0700 (PDT)\r
+Received: by finestructure.net (Postfix, from userid 1000)\r
+       id CFE6E3A9; Thu, 30 Aug 2012 09:33:58 -0700 (PDT)\r
+From: Jameson Graef Rollins <jrollins@finestructure.net>\r
+To: Michal Sojka <sojkam1@fel.cvut.cz>, Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: Re: [PATCH 01/11] lib: new thread addresses structure\r
+In-Reply-To: <87y5kw4cfo.fsf@steelpick.2x.cz>\r
+References: <1345427570-26518-1-git-send-email-jrollins@finestructure.net>\r
+       <1345427570-26518-2-git-send-email-jrollins@finestructure.net>\r
+       <87y5kw4cfo.fsf@steelpick.2x.cz>\r
+User-Agent: Notmuch/0.14+6~gb305ce9 (http://notmuchmail.org) Emacs/23.4.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Thu, 30 Aug 2012 09:33:56 -0700\r
+Message-ID: <874nnkpcej.fsf@servo.finestructure.net>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; boundary="=-=-=";\r
+       micalg=pgp-sha256; protocol="application/pgp-signature"\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: Thu, 30 Aug 2012 16:34:12 -0000\r
+\r
+--=-=-=\r
+\r
+Hey, Michal.  Thanks for the review.\r
+\r
+On Thu, Aug 30 2012, Michal Sojka <sojkam1@fel.cvut.cz> wrote:\r
+>> +/* Construct an addresses string from matched and unmatched addresses\r
+>> + * in notmuch_thread_addresses_t. The string contains matched\r
+>> + * addresses first, then non-matched addresses (with the two groups\r
+>> + * separated by '|'). Within each group, addresses are listed in date\r
+>> + * order. */\r
+>\r
+> I'd say the the addresses are listed in the order in which they have\r
+> been added, which might or might not be the date order.\r
+\r
+I actually did not write the _resolve_thread_addresses_string function.\r
+I left the logic and behavior unchanged, and just modified to use the\r
+new addresses structure.  If we think the logic should be changed, maybe\r
+we should do that in a separate patch.\r
+\r
+>> +static void\r
+>> +_resolve_thread_addresses_string (notmuch_thread_addresses_t *addresses)\r
+>> +{\r
+>> +    unsigned int i;\r
+>> +    char *address;\r
+>> +    int first_non_matched_address = 1;\r
+>> +\r
+>> +    /* First, list all matched addressses in date order. */\r
+>> +    for (i = 0; i < addresses->matched_array->len; i++) {\r
+>> +   address = (char *) g_ptr_array_index (addresses->matched_array, i);\r
+>> +   if (addresses->string)\r
+>> +       addresses->string = talloc_asprintf (addresses, "%s, %s",\r
+>> +                                            addresses->string,\r
+>> +                                            address);\r
+>> +   else\r
+>> +       addresses->string = address;\r
+>> +    }\r
+>> +\r
+>> +    /* Next, append any non-matched addresses that haven't already appeared. */\r
+>> +    for (i = 0; i < addresses->unmatched_array->len; i++) {\r
+>> +   address = (char *) g_ptr_array_index (addresses->unmatched_array, i);\r
+>> +   if (g_hash_table_lookup_extended (addresses->matched_hash,\r
+>> +                                     address, NULL, NULL))\r
+>> +       continue;\r
+>> +   if (first_non_matched_address) {\r
+>> +       addresses->string = talloc_asprintf (addresses, "%s| %s",\r
+>> +                                            addresses->string,\r
+>> +                                            address);\r
+>> +   } else {\r
+>> +       addresses->string = talloc_asprintf (addresses, "%s, %s",\r
+>> +                                            addresses->string,\r
+>> +                                            address);\r
+>> +   }\r
+>\r
+> Simpler would be:\r
+>\r
+> addresses->string = talloc_asprintf (addresses, "%s%c %s",\r
+>                                      addresses->string,\r
+>                                      first_non_matched_address ? '|' : ','\r
+>                                      address);\r
+>\r
+> Also, you might want to talloc_free the old address->string to not waste\r
+> memory in the case of long lived notmuch_thread_addresses_t object. Or\r
+> better use talloc_asprintf_append() function, which hopefully implements\r
+> freeing internally.\r
+\r
+This looks like a nice simplification, but see comment above.\r
+\r
+I'll look into including these changes in the next version of the\r
+series.\r
+\r
+jamie.\r
+\r
+--=-=-=\r
+Content-Type: application/pgp-signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v1.4.12 (GNU/Linux)\r
+\r
+iQIcBAEBCAAGBQJQP5X0AAoJEO00zqvie6q8+YQQAKrKycrpRrNJdqWg7d/0SwSP\r
+BU0GZsEPB2p7i8uKpwQ6CdnOKXHxme9mnMlD6MpTR5SZqqoOZaEkWRK/E5e8FBh4\r
+8Zh1OMgpwrPIy/hQAwMJ7/z718P4h34wjA8utB9WtHUJH6f+Hm2IDfV7MeHk/4mz\r
+FJmv87JH4cmj2Q8Clgp8HTbLeg15wyatc9eV+AT2AeRVcSo56AHBXTj34Q6Uj/3M\r
+Usq/7jLn7kukEr+pMcW+sXJWSEdV9asbAY7a7O63cuFg9mHJamkZAtajvJ5cBIw6\r
+y8D/SxWzv6XCg20oSgnhxfXxoE6WWOgdeDMQLdoT9KP/ywcvU4X9H7/bOkxnsp5G\r
++n+BKgDtbBE+CFVgYZ2MMZVWVkMh57xilvfsQXiRpj8UQvrgDxNnpKMxbD7MJln4\r
+72xLN1JbkdBjX0iGxdKfLs8o4DqLgbVFC4x6WJQCqmViY3i26oK8MVt6kwsTQFuY\r
+heoqqj5SsCSQfCdnmS6UiVnzhIw4kJK5+U7upHt/gL+JzDQ3kRcXQ740upUK2PCA\r
+hKtmquLgLxx6Tk2ksgYuT5TPBe92AcdBPirv/wSmM0Py92S02IWl26Rtjqm5GEVw\r
+iqSpLb1gvj2Xzj2QxEFMA6TX5voUUw/9tzrBb+IeatRxd6jMh7i2FF1oQOEQAsgr\r
+6swbWsOcduFoJRmv6nm0\r
+=k1/c\r
+-----END PGP SIGNATURE-----\r
+--=-=-=--\r