From: <aar...@us...> - 2006-06-23 16:02:51
|
Revision: 16319 Author: aaronsheldon Date: 2006-06-23 09:02:36 -0700 (Fri, 23 Jun 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16319&view=rev Log Message: ----------- Changes to gaim_gtk_blist_get_name_markup which result in profiling indicating a 40%+ improvement in function performance (larger gains when detailed buddy is turned off because it no longer grabs PRPL info first). Modified Paths: -------------- branches/soc-2006-blist-efficiency/src/gtkblist.c Modified: branches/soc-2006-blist-efficiency/src/gtkblist.c =================================================================== --- branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-06-23 14:30:27 UTC (rev 16318) +++ branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-06-23 16:02:36 UTC (rev 16319) @@ -2875,7 +2875,7 @@ struct _gaim_gtk_blist_node *gtkcontactnode = NULL; char *idletime = NULL, *statustext = NULL; time_t t; - /* XXX Clean up this crap */ + /* XXX Good luck cleaning up this crap */ contact = (GaimContact*)((GaimBlistNode*)b)->parent; if(contact) @@ -2887,11 +2887,6 @@ name = gaim_buddy_get_alias(b); esc = g_markup_escape_text(name, strlen(name)); - prpl = gaim_find_prpl(gaim_account_get_protocol_id(b->account)); - - if (prpl != NULL) - prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); - presence = gaim_buddy_get_presence(b); if (!gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) @@ -2907,6 +2902,11 @@ return esc; } + prpl = gaim_find_prpl(gaim_account_get_protocol_id(b->account)); + + if (prpl != NULL) + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); + if (prpl_info && prpl_info->status_text && b->account->gc) { char *tmp = prpl_info->status_text(b); const char *end; @@ -2957,59 +2957,62 @@ #endif } - if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time") && - gaim_presence_is_idle(presence)) - { - time_t idle_secs = gaim_presence_get_idle_time(presence); + if(!gaim_presence_is_online(presence) && !statustext) + statustext = g_strdup(_("Offline")); + else if (!statustext) + text = g_strdup(esc); + + if (gaim_presence_is_idle(presence)) { + if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time")) { + time_t idle_secs = gaim_presence_get_idle_time(presence); - if (idle_secs > 0) { - int ihrs, imin; + if (idle_secs > 0) { + int ihrs, imin; - time(&t); - ihrs = (t - idle_secs) / 3600; - imin = ((t - idle_secs) / 60) % 60; + time(&t); + ihrs = (t - idle_secs) / 3600; + imin = ((t - idle_secs) / 60) % 60; - if (ihrs) - idletime = g_strdup_printf(_("Idle %dh %02dm"), ihrs, imin); + if (ihrs) + idletime = g_strdup_printf(_("Idle %dh %02dm"), ihrs, imin); + else + idletime = g_strdup_printf(_("Idle %dm"), imin); + } else - idletime = g_strdup_printf(_("Idle %dm"), imin); + idletime = g_strdup(_("Idle")); + + if (!selected) + text = g_strdup_printf("<span color='%s'>%s</span>\n" + "<span color='%s' size='smaller'>%s%s%s</span>", + dim_grey(), esc, dim_grey(), + idletime != NULL ? idletime : "", + (idletime != NULL && statustext != NULL) ? " - " : "", + statustext != NULL ? statustext : ""); } - else - idletime = g_strdup(_("Idle")); + else if (!selected && !statustext) /* We handle selected text later */ + text = g_strdup_printf("<span color='%s'>%s</span>", dim_grey(), esc); + else if (!selected && !text) + text = g_strdup_printf("<span color='%s'>%s</span>\n" + "<span color='%s' size='smaller'>%s%s%s</span>", + dim_grey(), esc, dim_grey(), + idletime != NULL ? idletime : "", + (idletime != NULL && statustext != NULL) ? " - " : "", + statustext != NULL ? statustext : ""); } - if(!gaim_presence_is_online(presence) && !statustext) - statustext = g_strdup(_("Offline")); - - if (statustext == NULL && idletime == NULL) + /* Not idle and not selected */ + else if (!selected && !text) { - if (!selected && gaim_presence_is_idle(presence)) - text = g_strdup_printf("<span color='%s'>%s</span>", dim_grey(), esc); - else - text = g_strdup(esc); + text = g_strdup_printf("%s\n" + "<span color='%s' size='smaller'>%s%s%s</span>", + esc, dim_grey(), + idletime != NULL ? idletime : "", + (idletime != NULL && statustext != NULL) ? " - " : "", + statustext != NULL ? statustext : ""); } - else if (!selected) - { - if (gaim_presence_is_idle(presence)) - { - text = g_strdup_printf("<span color='%s'>%s</span>\n" - "<span color='%s' size='smaller'>%s%s%s</span>", - dim_grey(), esc, dim_grey(), - idletime != NULL ? idletime : "", - (idletime != NULL && statustext != NULL) ? " - " : "", - statustext != NULL ? statustext : ""); - } - else - { - text = g_strdup_printf("%s\n" - "<span color='%s' size='smaller'>%s%s%s</span>", - esc, dim_grey(), - idletime != NULL ? idletime : "", - (idletime != NULL && statustext != NULL) ? " - " : "", - statustext != NULL ? statustext : ""); - } - } - else + + /* It is selected. */ + if ((selected && !text) || (selected && idletime)) text = g_strdup_printf("%s\n" "<span size='smaller'>%s%s%s</span>", esc, @@ -3017,7 +3020,6 @@ (idletime != NULL && statustext != NULL) ? " - " : "", statustext != NULL ? statustext : ""); - g_free(idletime); g_free(statustext); g_free(esc); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |