aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-01-23 04:52:16 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-01-23 04:52:16 +0800
commitf87bf7fa7738b61a0d9bcfc8cb9905e4355ba396 (patch)
tree26aced249c783dd4daa41a1a2dfca54c32c2660f
parentcfe53117d6bb12b2983d756c802c02de62d59440 (diff)
downloadgsoc2013-evolution-f87bf7fa7738b61a0d9bcfc8cb9905e4355ba396.tar
gsoc2013-evolution-f87bf7fa7738b61a0d9bcfc8cb9905e4355ba396.tar.gz
gsoc2013-evolution-f87bf7fa7738b61a0d9bcfc8cb9905e4355ba396.tar.bz2
gsoc2013-evolution-f87bf7fa7738b61a0d9bcfc8cb9905e4355ba396.tar.lz
gsoc2013-evolution-f87bf7fa7738b61a0d9bcfc8cb9905e4355ba396.tar.xz
gsoc2013-evolution-f87bf7fa7738b61a0d9bcfc8cb9905e4355ba396.tar.zst
gsoc2013-evolution-f87bf7fa7738b61a0d9bcfc8cb9905e4355ba396.zip
Simplified.
2002-01-22 Jeffrey Stedfast <fejj@ximian.com> * mail-callbacks.c (guess_me): Simplified. svn path=/trunk/; revision=15424
-rw-r--r--mail/ChangeLog4
-rw-r--r--mail/mail-callbacks.c60
2 files changed, 34 insertions, 30 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index dd53afaba2..bb96c9d103 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,7 @@
+2002-01-22 Jeffrey Stedfast <fejj@ximian.com>
+
+ * mail-callbacks.c (guess_me): Simplified.
+
2002-01-21 Jeffrey Stedfast <fejj@ximian.com>
* mail-format.c (handle_text_plain): If the first "token" in the
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index 7dd6e830cb..e367ab4638 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -842,47 +842,47 @@ list_add_addresses (GList *list, const CamelInternetAddress *cia, const GSList *
static const MailConfigAccount *
guess_me (const CamelInternetAddress *to, const CamelInternetAddress *cc, const GSList *accounts)
{
- const char *name, *addr;
+ const MailConfigAccount *account;
+ GHashTable *account_hash;
+ const char *addr;
const GSList *l;
- gboolean notme;
- char *full;
int i;
+ /* "optimization" */
+ if (!to && !cc)
+ return NULL;
+
+ account_hash = g_hash_table_new (g_strcase_hash, g_strcase_equal);
+ l = accounts;
+ while (l) {
+ account = l->data;
+ g_hash_table_insert (account_hash, (char *) account->id->address, (void *) account);
+ l = l->next;
+ }
+
if (to) {
- for (i = 0; camel_internet_address_get (to, i, &name, &addr); i++) {
- full = camel_internet_address_format_address (name, addr);
- l = accounts;
- while (l) {
- const MailConfigAccount *acnt = l->data;
-
- if (!g_strcasecmp (acnt->id->address, addr)) {
- notme = FALSE;
- return acnt;
- }
-
- l = l->next;
- }
+ for (i = 0; camel_internet_address_get (to, i, NULL, &addr); i++) {
+ account = g_hash_table_lookup (account_hash, addr);
+ if (account)
+ goto found;
}
}
if (cc) {
- for (i = 0; camel_internet_address_get (cc, i, &name, &addr); i++) {
- full = camel_internet_address_format_address (name, addr);
- l = accounts;
- while (l) {
- const MailConfigAccount *acnt = l->data;
-
- if (!g_strcasecmp (acnt->id->address, addr)) {
- notme = FALSE;
- return acnt;
- }
-
- l = l->next;
- }
+ for (i = 0; camel_internet_address_get (cc, i, NULL, &addr); i++) {
+ account = g_hash_table_lookup (account_hash, addr);
+ if (account)
+ goto found;
}
}
- return NULL;
+ account = NULL;
+
+ found:
+
+ g_hash_table_destroy (account_hash);
+
+ return account;
}
static EMsgComposer *