diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-01-23 04:52:16 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-01-23 04:52:16 +0800 |
commit | f87bf7fa7738b61a0d9bcfc8cb9905e4355ba396 (patch) | |
tree | 26aced249c783dd4daa41a1a2dfca54c32c2660f /mail/mail-callbacks.c | |
parent | cfe53117d6bb12b2983d756c802c02de62d59440 (diff) | |
download | gsoc2013-evolution-f87bf7fa7738b61a0d9bcfc8cb9905e4355ba396.tar.gz 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
Diffstat (limited to 'mail/mail-callbacks.c')
-rw-r--r-- | mail/mail-callbacks.c | 60 |
1 files changed, 30 insertions, 30 deletions
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 * |