# HG changeset patch # User Mark Doliner # Date 1175581580 0 # Node ID 6dc5dc83a61b70649bf96c677ff38c52ed83322f # Parent 20c0ab6ea00852ff1a30658cb83c5de49a637865 Add a whimpy ui op to the debug API that returns TRUE if debugging is turned on in the UI. This allows the core to avoid having a call to g_strdup_vprintf() for each debug message when debugging is turned off. The change should provide a very very small speed improvement, since we tend to print a lot of debug output. diff -r 20c0ab6ea008 -r 6dc5dc83a61b finch/gntdebug.c --- a/finch/gntdebug.c Mon Apr 02 00:38:21 2007 +0000 +++ b/finch/gntdebug.c Tue Apr 03 06:26:20 2007 +0000 @@ -106,9 +106,16 @@ } } +static gboolean +finch_debug_is_enabled(PurpleDebugLevel level, const char *category) +{ + return debug.window && !debug.paused; +} + static PurpleDebugUiOps uiops = { finch_debug_print, + finch_debug_is_enabled }; PurpleDebugUiOps *finch_debug_get_ui_ops() diff -r 20c0ab6ea008 -r 6dc5dc83a61b libpurple/debug.c --- a/libpurple/debug.c Mon Apr 02 00:38:21 2007 +0000 +++ b/libpurple/debug.c Tue Apr 03 06:26:20 2007 +0000 @@ -53,7 +53,8 @@ ops = purple_debug_get_ui_ops(); - if (!debug_enabled && ((ops == NULL) || (ops->print == NULL))) + if (!debug_enabled && ((ops == NULL) || (ops->print == NULL) || + (ops->is_enabled && !ops->is_enabled(level, category)))) return; arg_s = g_strdup_vprintf(format, args); diff -r 20c0ab6ea008 -r 6dc5dc83a61b libpurple/debug.h --- a/libpurple/debug.h Mon Apr 02 00:38:21 2007 +0000 +++ b/libpurple/debug.h Tue Apr 03 06:26:20 2007 +0000 @@ -49,6 +49,8 @@ { void (*print)(PurpleDebugLevel level, const char *category, const char *arg_s); + gboolean (*is_enabled)(PurpleDebugLevel level, + const char *category); } PurpleDebugUiOps; #ifdef __cplusplus diff -r 20c0ab6ea008 -r 6dc5dc83a61b pidgin/gtkdebug.c --- a/pidgin/gtkdebug.c Mon Apr 02 00:38:21 2007 +0000 +++ b/pidgin/gtkdebug.c Tue Apr 03 06:26:20 2007 +0000 @@ -1104,9 +1104,17 @@ g_free(s); } +static gboolean +pidgin_debug_is_enabled(PurpleDebugLevel level, const char *category) +{ + return (purple_prefs_get_bool("/purple/gtk/debug/enabled") && + debug_win != NULL); +} + static PurpleDebugUiOps ops = { pidgin_debug_print, + pidgin_debug_is_enabled }; PurpleDebugUiOps *