util/u_debug: Use 'initialized' instead of 'first'

Using 'initialized' to guard the one-time init, means it can be set to
false as part of .bss instead setting 'first' to true in .data.  This
is more efficient and works at .ctor time.

Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16952>
This commit is contained in:
Kristian H. Kristensen
2022-06-09 14:11:44 -04:00
committed by Marge Bot
parent 1f323437df
commit 279f32e042
3 changed files with 21 additions and 21 deletions
+3 -3
View File
@@ -121,16 +121,16 @@ debug_print_blob(const char *name, const void *blob, unsigned size)
static bool
debug_get_option_should_print(void)
{
static bool first = true;
static bool initialized = false;
static bool value = false;
if (!first)
if (initialized)
return value;
/* Oh hey this will call into this function,
* but its cool since we set first to false
*/
first = false;
initialized = true;
value = debug_get_bool_option("GALLIUM_PRINT_OPTIONS", false);
/* XXX should we print this option? Currently it wont */
return value;