Re: [PATCH spice-gtk 06/10] util: avoid calling getenv for every SPICE_DEBUG

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ack
On 09/08/2013 02:59 PM, Marc-André Lureau wrote:
From: Marc-André Lureau <marcandre.lureau@xxxxxxxxx>

That doesn't seem to really improve performance so much,
but that' s what we should do probably.
---
  gtk/spice-util.c | 13 ++++++++++---
  1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/gtk/spice-util.c b/gtk/spice-util.c
index e02fc4d..4372f28 100644
--- a/gtk/spice-util.c
+++ b/gtk/spice-util.c
@@ -39,7 +39,7 @@
   * Various functions for debugging and informational purposes.
   */

-static gboolean debugFlag = FALSE;
+static GOnce debug_once = G_ONCE_INIT;

  /**
   * spice_util_set_debug:
@@ -61,12 +61,19 @@ void spice_util_set_debug(gboolean enabled)
          }
      }
  #endif
-    debugFlag = enabled;
+    debug_once.retval = GINT_TO_POINTER(enabled);
+}
+
+static gpointer getenv_debug(gpointer data)
+{
+    return GINT_TO_POINTER(g_getenv("SPICE_DEBUG") != NULL);
  }

  gboolean spice_util_get_debug(void)
  {
-    return debugFlag || g_getenv("SPICE_DEBUG") != NULL;
+    g_once(&debug_once, getenv_debug, NULL);
+
+    return GPOINTER_TO_INT(debug_once.retval);
  }

  /**


_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]