From dfe15c0e1b18f4d9ab5d328399e56b3be4a251a5 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Thu, 3 Sep 2015 22:39:57 +0300 Subject: [PATCH] cli: g_hash_table_lookup_extended is overkill 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 3076c3f6..7fdc6aca 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