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