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.
This commit is contained in:
Jani Nikula 2015-09-03 22:39:57 +03:00 committed by David Bremner
parent 1008fc45da
commit dfe15c0e1b

View file

@ -248,7 +248,6 @@ do_search_threads (search_context_t *ctx)
static notmuch_bool_t static notmuch_bool_t
is_duplicate (const search_context_t *ctx, const char *name, const char *addr) is_duplicate (const search_context_t *ctx, const char *name, const char *addr)
{ {
notmuch_bool_t duplicate;
char *key; char *key;
mailbox_t *mailbox; mailbox_t *mailbox;
@ -256,20 +255,20 @@ is_duplicate (const search_context_t *ctx, const char *name, const char *addr)
if (! key) if (! key)
return FALSE; return FALSE;
duplicate = g_hash_table_lookup_extended (ctx->addresses, key, NULL, (gpointer)&mailbox); mailbox = g_hash_table_lookup (ctx->addresses, key);
if (mailbox) {
mailbox->count++;
talloc_free (key);
return TRUE;
}
if (! duplicate) {
mailbox = talloc (ctx->format, mailbox_t); mailbox = talloc (ctx->format, mailbox_t);
mailbox->name = talloc_strdup (mailbox, name); mailbox->name = talloc_strdup (mailbox, name);
mailbox->addr = talloc_strdup (mailbox, addr); mailbox->addr = talloc_strdup (mailbox, addr);
mailbox->count = 1; mailbox->count = 1;
g_hash_table_insert (ctx->addresses, key, mailbox); g_hash_table_insert (ctx->addresses, key, mailbox);
} else {
mailbox->count++;
talloc_free (key);
}
return duplicate; return FALSE;
} }
static void static void