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 1C4586DE14F4 for ; Thu, 3 Sep 2015 12:40:15 -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.402 X-Spam-Level: X-Spam-Status: No, score=-0.402 tagged_above=-999 required=5 tests=[AWL=0.318, 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 pZTB8h-iiALy for ; Thu, 3 Sep 2015 12:40:13 -0700 (PDT) Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by arlo.cworth.org (Postfix) with ESMTPS id 162086DE1533 for ; Thu, 3 Sep 2015 12:40:13 -0700 (PDT) Received: by wicge5 with SMTP id ge5so84699959wic.0 for ; Thu, 03 Sep 2015 12:40:11 -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=H6YFLaMpaYMmkTg7LhRHDwy8jSrRIb6BbrVa/E9K9tICXxVucP3JlyQILG6cGKFcH6 z5Mwqj2blQuSxnYAq46oSb2Xhym1JfdJOkTKS9FUbWWYdVUDGLv20Bo14E92tmxSk4bJ 7l91Yf0U5PjXLPlzy0lvYhKL3zGZbbRdWFG1/tm0JKe4cks22Zf1XVtVwttKc8HyoCKH X6hijvgokyducSl+KvY9iZjqmGTMD9UY+u81ZaXWybscSqfl8yIWWg0lBuz0KVU/0YZS 4ynyzGo482Y6f8oy18/hOGDCOq/nWG70iMX4RS3XEPeNYag9Ej753UvRXXoyUxu54s6F vgyQ== X-Gm-Message-State: ALoCoQl6gz9bo05YuhXx12DCWwemBRZQdpfzK45PxvCV3ZVJC1KD7pfam9IjXsZkCrnandeEX7gt X-Received: by 10.180.23.132 with SMTP id m4mr1359977wif.89.1441309211337; Thu, 03 Sep 2015 12:40:11 -0700 (PDT) Received: from localhost (mobile-access-bcee4f-131.dhcp.inet.fi. [188.238.79.131]) by smtp.gmail.com with ESMTPSA id bq7sm39243253wjc.31.2015.09.03.12.40.10 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Sep 2015 12:40:10 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH v2 1/9] cli: g_hash_table_lookup_extended is overkill Date: Thu, 3 Sep 2015 22:39:57 +0300 Message-Id: <4e640f9d373e9c07129e6f1f0ddbe4d1bb4febd9.1441308761.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: Thu, 03 Sep 2015 19:40:15 -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