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