[RFC PATCH 1/5] cli: g_hash_table_lookup_extended is overkill
authorJani Nikula <jani@nikula.org>
Sat, 29 Aug 2015 14:56:32 +0000 (17:56 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:49:26 +0000 (14:49 -0700)
90/130a6ad2fc85237c90b4fb383e1fde70751f25 [new file with mode: 0644]

diff --git a/90/130a6ad2fc85237c90b4fb383e1fde70751f25 b/90/130a6ad2fc85237c90b4fb383e1fde70751f25
new file mode 100644 (file)
index 0000000..a5cf388
--- /dev/null
@@ -0,0 +1,121 @@
+Return-Path: <jani@nikula.org>\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 4D82B6DE00CB\r
+ for <notmuch@notmuchmail.org>; Sat, 29 Aug 2015 07:56:45 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.319\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.319 tagged_above=-999 required=5 tests=[AWL=0.401,\r
+  RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01]\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 4Igz_n-P_MNA for <notmuch@notmuchmail.org>;\r
+ Sat, 29 Aug 2015 07:56:43 -0700 (PDT)\r
+Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com\r
+ [209.85.212.180])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 3415A6DE1422\r
+ for <notmuch@notmuchmail.org>; Sat, 29 Aug 2015 07:56:43 -0700 (PDT)\r
+Received: by widfa3 with SMTP id fa3so579924wid.1\r
+ for <notmuch@notmuchmail.org>; Sat, 29 Aug 2015 07:56:41 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references:in-reply-to:references;\r
+ bh=oOK9FwQQJYfJ8EEw/WSzOC9eP/5F8JfiWJh6LE9dUxo=;\r
+ b=ErH4jZ5YJKr1e3j2xzo7W8a8/aK/0/2Cj6TTOaZqwgGPIjZc6huE/oKcB5U/D/Oo98\r
+ OistkQaVMYU8a2ZRGhcZWugtv8IltNWrJehRwj8TYyLPhxhxHY1lQdFQXibMXUrGiaAZ\r
+ romS21xTudrauzb15IM9s8noFcw8m0d1rPgMLDxt56+v2oZDO9yxMXKeOhQiH0Ro+BMG\r
+ vbfkBfMIIU7/uVNbXghu2SP6YxMOZ8qsZgW8Vth5218miytk2Ko1izuKRZ9nD4E8jbaQ\r
+ ZWLWhxnfhGCl5FmZYEJWUM+s4vzwdpNrVThpRQamLvscyP3Fu5alOs65deshvj1eh4nc\r
+ pQcA==\r
+X-Gm-Message-State:\r
+ ALoCoQkOkWrx8zB+YnHG3hz82FOFMKysDXJ2EPI2oiGXRNKkBan1pn2BuCpeEg8ke3nLWw902Y5R\r
+X-Received: by 10.180.186.41 with SMTP id fh9mr10190716wic.7.1440860201723;\r
+ Sat, 29 Aug 2015 07:56:41 -0700 (PDT)\r
+Received: from localhost (mobile-access-bcee4f-131.dhcp.inet.fi.\r
+ [188.238.79.131])\r
+ by smtp.gmail.com with ESMTPSA id kb1sm13165728wjc.24.2015.08.29.07.56.40\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sat, 29 Aug 2015 07:56:41 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [RFC PATCH 1/5] cli: g_hash_table_lookup_extended is overkill\r
+Date: Sat, 29 Aug 2015 17:56:32 +0300\r
+Message-Id:\r
+ <4e640f9d373e9c07129e6f1f0ddbe4d1bb4febd9.1440859765.git.jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <cover.1440859765.git.jani@nikula.org>\r
+References: <cover.1440859765.git.jani@nikula.org>\r
+In-Reply-To: <cover.1440859765.git.jani@nikula.org>\r
+References: <cover.1440859765.git.jani@nikula.org>\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: Sat, 29 Aug 2015 14:56:45 -0000\r
+\r
+Switch to normal glib hash table lookup. The extended version is only\r
+required if the values may contain NULL.\r
+---\r
+ notmuch-search.c | 21 ++++++++++-----------\r
+ 1 file changed, 10 insertions(+), 11 deletions(-)\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 3076c3f637b1..7fdc6acaa2fe 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -248,7 +248,6 @@ do_search_threads (search_context_t *ctx)\r
+ static notmuch_bool_t\r
+ is_duplicate (const search_context_t *ctx, const char *name, const char *addr)\r
+ {\r
+-    notmuch_bool_t duplicate;\r
+     char *key;\r
+     mailbox_t *mailbox;\r
\r
+@@ -256,20 +255,20 @@ is_duplicate (const search_context_t *ctx, const char *name, const char *addr)\r
+     if (! key)\r
+       return FALSE;\r
\r
+-    duplicate = g_hash_table_lookup_extended (ctx->addresses, key, NULL, (gpointer)&mailbox);\r
+-\r
+-    if (! duplicate) {\r
+-      mailbox = talloc (ctx->format, mailbox_t);\r
+-      mailbox->name = talloc_strdup (mailbox, name);\r
+-      mailbox->addr = talloc_strdup (mailbox, addr);\r
+-      mailbox->count = 1;\r
+-      g_hash_table_insert (ctx->addresses, key, mailbox);\r
+-    } else {\r
++    mailbox = g_hash_table_lookup (ctx->addresses, key);\r
++    if (mailbox) {\r
+       mailbox->count++;\r
+       talloc_free (key);\r
++      return TRUE;\r
+     }\r
\r
+-    return duplicate;\r
++    mailbox = talloc (ctx->format, mailbox_t);\r
++    mailbox->name = talloc_strdup (mailbox, name);\r
++    mailbox->addr = talloc_strdup (mailbox, addr);\r
++    mailbox->count = 1;\r
++    g_hash_table_insert (ctx->addresses, key, mailbox);\r
++\r
++    return FALSE;\r
+ }\r
\r
+ static void\r
+-- \r
+2.1.4\r
+\r