From 1f33373505c9f42a9c9d764431a0b53bf993d31b Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Tue, 11 Mar 2008 12:22:19 +0000 Subject: Lazy init of contact hash. svn path=/trunk/; revision=746 --- libempathy/empathy-contact.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libempathy/empathy-contact.c') diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index 13b526041..d841a1b76 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -52,6 +52,7 @@ struct _EmpathyContactPriv { guint handle; EmpathyCapabilities capabilities; gboolean is_user; + guint hash; }; static void empathy_contact_class_init (EmpathyContactClass *class); @@ -689,15 +690,15 @@ guint empathy_contact_hash (gconstpointer key) { EmpathyContactPriv *priv; - guint hash; g_return_val_if_fail (EMPATHY_IS_CONTACT (key), +1); priv = GET_PRIV (EMPATHY_CONTACT (key)); - hash = empathy_account_hash (empathy_contact_get_account (EMPATHY_CONTACT (key))); - hash += g_str_hash (empathy_contact_get_id (EMPATHY_CONTACT (key))); + if (priv->hash == 0) { + priv->hash = empathy_account_hash (priv->account) + g_str_hash (priv->id); + } - return hash; + return priv->hash; } -- cgit v1.2.3