Re: [RFC PATCH 4/5] cli: change the data structure for notmuch address deduplication
authorDavid Bremner <david@tethera.net>
Sun, 30 Aug 2015 01:48:53 +0000 (22:48 +2100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:49:27 +0000 (14:49 -0700)
c1/954d986c2cf06f80e6b4ed8c54724c1ee9fe46 [new file with mode: 0644]

diff --git a/c1/954d986c2cf06f80e6b4ed8c54724c1ee9fe46 b/c1/954d986c2cf06f80e6b4ed8c54724c1ee9fe46
new file mode 100644 (file)
index 0000000..3bb7b8b
--- /dev/null
@@ -0,0 +1,112 @@
+Return-Path: <david@tethera.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 arlo.cworth.org (Postfix) with ESMTP id 6173B6DE00CB\r
+ for <notmuch@notmuchmail.org>; Sat, 29 Aug 2015 18:51:02 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.118\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.118 tagged_above=-999 required=5 tests=[AWL=0.118]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id omYwb3QU_2zq for <notmuch@notmuchmail.org>;\r
+ Sat, 29 Aug 2015 18:51:00 -0700 (PDT)\r
+Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 9A3726DE005F\r
+ for <notmuch@notmuchmail.org>; Sat, 29 Aug 2015 18:51:00 -0700 (PDT)\r
+Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
+ (envelope-from <david@tethera.net>)\r
+ id 1ZVrk9-0005Vn-Fe; Sun, 30 Aug 2015 01:49:13 +0000\r
+Received: (nullmailer pid 19707 invoked by uid 1000); Sun, 30 Aug 2015\r
+ 01:48:53 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
+Subject: Re: [RFC PATCH 4/5] cli: change the data structure for notmuch\r
+ address deduplication\r
+In-Reply-To:\r
+ <ffe5975fd070d3e8e22602b01ceb8bf0d7d47ae0.1440859765.git.jani@nikula.org>\r
+References: <cover.1440859765.git.jani@nikula.org>\r
+ <ffe5975fd070d3e8e22602b01ceb8bf0d7d47ae0.1440859765.git.jani@nikula.org>\r
+User-Agent: Notmuch/0.20.2+60~gcb08a2e (http://notmuchmail.org) Emacs/24.5.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sat, 29 Aug 2015 22:48:53 -0300\r
+Message-ID: <87a8t9tuka.fsf@maritornes.cs.unb.ca>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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: Sun, 30 Aug 2015 01:51:02 -0000\r
+\r
+Jani Nikula <jani@nikula.org> writes:\r
+\r
+>  \r
+> +static int\r
+> +strcase_equal (const void *a, const void *b)\r
+> +{\r
+> +    return strcasecmp (a, b) == 0;\r
+> +}\r
+> +\r
+> +static unsigned int\r
+> +strcase_hash (const void *ptr)\r
+> +{\r
+> +    const char *s = ptr;\r
+> +\r
+> +    /* This is the djb2 hash. */\r
+> +    unsigned int hash = 5381;\r
+> +    while (s && *s) {\r
+> +    hash = ((hash << 5) + hash) + tolower (*s);\r
+> +    s++;\r
+> +    }\r
+> +\r
+> +    return hash;\r
+> +}\r
+> +\r
+\r
+as discussed, these functions probably need to be factored out into\r
+libutil.\r
+\r
+> +    l = g_list_find_custom (list, mailbox, mailbox_compare);\r
+> +    if (l) {\r
+> +        talloc_free (mailbox);\r
+> +        mailbox = l->data;\r
+> +        mailbox->count++;\r
+> +        return TRUE;\r
+> +    }\r
+\r
+I found this use of mailbox as a temporary variable confusing; despite\r
+the obvious return I thought it might have something to do with the\r
+g_list_append below.  Maybe just make a block scope temporary variable?\r
+\r
+> +\r
+> +    g_list_append (list, mailbox);\r
+> +    return FALSE;\r
+>      }\r
+>  \r
+> -    mailbox = new_mailbox (ctx->format, name, addr);\r
+> -    if (! mailbox)\r
+> +    key = talloc_strdup (ctx->format, addr);\r
+> +    if (! key)\r
+>      return FALSE;\r
+\r
+I guess this doesn't make the error handling worse; both old and new\r
+code silently ignore OOM if I understand correctly. Do you happen to\r
+understand the original choice of using ctx->format rather than that\r
+ctx->notmuch for a talloc parent? it doesn't seem to get deallocated any\r
+earlier.\r
+\r
+d\r
+\r
+\r