From de978d42317423ceb3041d773913473d564a0ec4 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 11 Jan 2013 13:00:56 -0500 Subject: Use g_hash_table_add() when using a hash table as a set. g_hash_table_add(table, key) uses less memory than g_hash_table_insert(table, key, GINT_TO_POINTER (1)). Also use g_hash_table_contains() when testing for membership. --- composer/e-msg-composer.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'composer') diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 82f1b30f96..8d0252cc21 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -3041,10 +3041,7 @@ composer_add_auto_recipients (ESource *source, const gchar *addr; if (camel_internet_address_get (inet_addr, ii, &name, &addr)) - g_hash_table_insert ( - hash_table, - g_strdup (addr), - GINT_TO_POINTER (1)); + g_hash_table_add (hash_table, g_strdup (addr)); } g_object_unref (inet_addr); @@ -3127,12 +3124,14 @@ e_msg_composer_new_with_message (EShell *shell, if (postto == NULL) { auto_cc = g_hash_table_new_full ( - camel_strcase_hash, camel_strcase_equal, + (GHashFunc) camel_strcase_hash, + (GEqualFunc) camel_strcase_equal, (GDestroyNotify) g_free, (GDestroyNotify) NULL); auto_bcc = g_hash_table_new_full ( - camel_strcase_hash, camel_strcase_equal, + (GHashFunc) camel_strcase_hash, + (GEqualFunc) camel_strcase_equal, (GDestroyNotify) g_free, (GDestroyNotify) NULL); @@ -3169,7 +3168,7 @@ e_msg_composer_new_with_message (EShell *shell, e_destination_set_name (dest, name); e_destination_set_email (dest, addr); - if (g_hash_table_lookup (auto_cc, addr)) + if (g_hash_table_contains (auto_cc, addr)) e_destination_set_auto_recipient (dest, TRUE); Cc = g_list_append (Cc, dest); @@ -3189,7 +3188,7 @@ e_msg_composer_new_with_message (EShell *shell, e_destination_set_name (dest, name); e_destination_set_email (dest, addr); - if (g_hash_table_lookup (auto_bcc, addr)) + if (g_hash_table_contains (auto_bcc, addr)) e_destination_set_auto_recipient (dest, TRUE); Bcc = g_list_append (Bcc, dest); -- cgit v1.2.3