aboutsummaryrefslogtreecommitdiffstats
path: root/libemail-engine
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-01-12 02:00:56 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-01-12 02:43:19 +0800
commitde978d42317423ceb3041d773913473d564a0ec4 (patch)
tree93caed2beebd7779ae5f6d35669d65cea0146469 /libemail-engine
parentadc0ad91c4e187d814d41edd69a6c53c6405f235 (diff)
downloadgsoc2013-evolution-de978d42317423ceb3041d773913473d564a0ec4.tar
gsoc2013-evolution-de978d42317423ceb3041d773913473d564a0ec4.tar.gz
gsoc2013-evolution-de978d42317423ceb3041d773913473d564a0ec4.tar.bz2
gsoc2013-evolution-de978d42317423ceb3041d773913473d564a0ec4.tar.lz
gsoc2013-evolution-de978d42317423ceb3041d773913473d564a0ec4.tar.xz
gsoc2013-evolution-de978d42317423ceb3041d773913473d564a0ec4.tar.zst
gsoc2013-evolution-de978d42317423ceb3041d773913473d564a0ec4.zip
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.
Diffstat (limited to 'libemail-engine')
-rw-r--r--libemail-engine/e-mail-utils.c10
-rw-r--r--libemail-engine/em-vfolder-rule.c21
2 files changed, 19 insertions, 12 deletions
diff --git a/libemail-engine/e-mail-utils.c b/libemail-engine/e-mail-utils.c
index 30eee6242a..750e8cce51 100644
--- a/libemail-engine/e-mail-utils.c
+++ b/libemail-engine/e-mail-utils.c
@@ -1104,7 +1104,7 @@ mail_account_in_recipients (ESourceRegistry *registry,
g_object_unref (source);
if (address != NULL) {
- match = (g_hash_table_lookup (recipients, address) != NULL);
+ match = g_hash_table_contains (recipients, address);
g_free (address);
}
@@ -1141,9 +1141,7 @@ em_utils_guess_mail_account_with_recipients (ESourceRegistry *registry,
gint index = 0;
while (camel_internet_address_get (addr, index++, NULL, &key))
- g_hash_table_insert (
- recipients, (gpointer) key,
- GINT_TO_POINTER (1));
+ g_hash_table_add (recipients, (gpointer) key);
}
type = CAMEL_RECIPIENT_TYPE_CC;
@@ -1152,9 +1150,7 @@ em_utils_guess_mail_account_with_recipients (ESourceRegistry *registry,
gint index = 0;
while (camel_internet_address_get (addr, index++, NULL, &key))
- g_hash_table_insert (
- recipients, (gpointer) key,
- GINT_TO_POINTER (1));
+ g_hash_table_add (recipients, (gpointer) key);
}
/* First Preference: We were given a folder that maps to an
diff --git a/libemail-engine/em-vfolder-rule.c b/libemail-engine/em-vfolder-rule.c
index 0d6b07a8ff..ec6fdcabfd 100644
--- a/libemail-engine/em-vfolder-rule.c
+++ b/libemail-engine/em-vfolder-rule.c
@@ -113,7 +113,9 @@ em_vfolder_rule_init (EMVFolderRule *rule)
rule->priv->autoupdate = TRUE;
/* it's using pointers from priv::sources, and those
* included has include_subfolders set to true */
- rule->priv->include_subfolders = g_hash_table_new (g_direct_hash, g_direct_equal);
+ rule->priv->include_subfolders = g_hash_table_new (
+ (GHashFunc) g_direct_hash,
+ (GEqualFunc) g_direct_equal);
rule->rule.source = g_strdup ("incoming");
}
@@ -214,7 +216,8 @@ em_vfolder_rule_sources_changed (EMVFolderRule *rule)
{
g_return_if_fail (rule != NULL);
- g_hash_table_foreach_remove (rule->priv->include_subfolders,
+ g_hash_table_foreach_remove (
+ rule->priv->include_subfolders,
check_queue_has_key, rule);
}
@@ -227,7 +230,11 @@ em_vfolder_rule_source_get_include_subfolders (EMVFolderRule *rule,
source = em_vfolder_rule_find_source (rule, source);
- return source && g_hash_table_lookup (rule->priv->include_subfolders, source);
+ if (source == NULL)
+ return FALSE;
+
+ return g_hash_table_contains (
+ rule->priv->include_subfolders, source);
}
void
@@ -242,9 +249,13 @@ em_vfolder_rule_source_set_include_subfolders (EMVFolderRule *rule,
g_return_if_fail (source != NULL);
if (include_subfolders)
- g_hash_table_insert (rule->priv->include_subfolders, (gpointer) source, GINT_TO_POINTER (1));
+ g_hash_table_add (
+ rule->priv->include_subfolders,
+ (gpointer) source);
else
- g_hash_table_remove (rule->priv->include_subfolders, (gpointer) source);
+ g_hash_table_remove (
+ rule->priv->include_subfolders,
+ (gpointer) source);
}
void