util: Don't expand meta_*() debug log arguments if topic not enabled
It's pointless to call into functions that produce information that will end up nowhere, so lets not. This will generate less angst when doing more intense data gathering and string generation in debug log calls. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1467
This commit is contained in:
parent
f79d40077e
commit
43c6f70605
@ -285,6 +285,18 @@ topic_name (MetaDebugTopic topic)
|
|||||||
|
|
||||||
static int sync_count = 0;
|
static int sync_count = 0;
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_is_topic_enabled (MetaDebugTopic topic)
|
||||||
|
{
|
||||||
|
if (verbose_topics == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (topic == META_DEBUG_VERBOSE && verbose_topics != META_DEBUG_VERBOSE)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return !!(verbose_topics & topic);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_topic_real_valist (MetaDebugTopic topic,
|
meta_topic_real_valist (MetaDebugTopic topic,
|
||||||
const char *format,
|
const char *format,
|
||||||
@ -295,9 +307,7 @@ meta_topic_real_valist (MetaDebugTopic topic,
|
|||||||
|
|
||||||
g_return_if_fail (format != NULL);
|
g_return_if_fail (format != NULL);
|
||||||
|
|
||||||
if (verbose_topics == 0
|
if (!meta_is_topic_enabled (topic))
|
||||||
|| (topic == META_DEBUG_VERBOSE && verbose_topics != META_DEBUG_VERBOSE)
|
|
||||||
|| (!(verbose_topics & topic)))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
str = g_strdup_vprintf (format, args);
|
str = g_strdup_vprintf (format, args);
|
||||||
|
@ -112,6 +112,9 @@ typedef enum
|
|||||||
META_DEBUG_PAINT_OPAQUE_REGION = 1 << 0,
|
META_DEBUG_PAINT_OPAQUE_REGION = 1 << 0,
|
||||||
} MetaDebugPaintFlag;
|
} MetaDebugPaintFlag;
|
||||||
|
|
||||||
|
META_EXPORT
|
||||||
|
gboolean meta_is_topic_enabled (MetaDebugTopic topic);
|
||||||
|
|
||||||
META_EXPORT
|
META_EXPORT
|
||||||
void meta_topic_real (MetaDebugTopic topic,
|
void meta_topic_real (MetaDebugTopic topic,
|
||||||
const char *format,
|
const char *format,
|
||||||
@ -162,8 +165,21 @@ GPid meta_show_dialog (const char *type,
|
|||||||
/* To disable verbose mode, we make these functions into no-ops */
|
/* To disable verbose mode, we make these functions into no-ops */
|
||||||
#ifdef WITH_VERBOSE_MODE
|
#ifdef WITH_VERBOSE_MODE
|
||||||
|
|
||||||
#define meta_verbose meta_verbose_real
|
#define meta_verbose(...) \
|
||||||
#define meta_topic meta_topic_real
|
G_STMT_START \
|
||||||
|
{ \
|
||||||
|
if (meta_is_topic_enabled (META_DEBUG_VERBOSE)) \
|
||||||
|
meta_verbose_real (__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
G_STMT_END
|
||||||
|
|
||||||
|
#define meta_topic(debug_topic,...) \
|
||||||
|
G_STMT_START \
|
||||||
|
{ \
|
||||||
|
if (meta_is_topic_enabled (debug_topic)) \
|
||||||
|
meta_topic_real (debug_topic, __VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
G_STMT_END
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user