From: Jani Nikula Date: Thu, 3 Sep 2015 19:39:57 +0000 (+0300) Subject: cli: g_hash_table_lookup_extended is overkill X-Git-Tag: 0.21_rc0~44 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=dfe15c0e1b18f4d9ab5d328399e56b3be4a251a5 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. --- 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