[glib] gquark: simplify g_quark_from_static_string/g_quark_from_string



commit 2f07630b4305321c175eb5af11531ae02752573b
Author: Natanael Copa <ncopa alpinelinux org>
Date:   Wed Jul 6 16:23:48 2016 +0200

    gquark: simplify g_quark_from_static_string/g_quark_from_string
    
    Move common code to quark_from_string_locked  wrapper function. This has
    no effect on generated code but it makes codebase a bit cleaner.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768507

 glib/gquark.c | 38 ++++++++++++++++++--------------------
 1 file changed, 18 insertions(+), 20 deletions(-)
---
diff --git a/glib/gquark.c b/glib/gquark.c
index 7845621fa..295430401 100644
--- a/glib/gquark.c
+++ b/glib/gquark.c
@@ -190,6 +190,22 @@ quark_from_string (const gchar *string,
   return quark;
 }
 
+static inline GQuark
+quark_from_string_locked (const gchar   *string,
+                          gboolean       duplicate)
+{
+  GQuark quark = 0;
+
+  if (!string)
+    return 0;
+
+  G_LOCK (quark_global);
+  quark = quark_from_string (string, duplicate);
+  G_UNLOCK (quark_global);
+
+  return quark;
+}
+
 /**
  * g_quark_from_string:
  * @string: (nullable): a string
@@ -203,16 +219,7 @@ quark_from_string (const gchar *string,
 GQuark
 g_quark_from_string (const gchar *string)
 {
-  GQuark quark;
-
-  if (!string)
-    return 0;
-
-  G_LOCK (quark_global);
-  quark = quark_from_string (string, TRUE);
-  G_UNLOCK (quark_global);
-
-  return quark;
+  return quark_from_string_locked (string, TRUE);
 }
 
 /**
@@ -237,16 +244,7 @@ g_quark_from_string (const gchar *string)
 GQuark
 g_quark_from_static_string (const gchar *string)
 {
-  GQuark quark;
-
-  if (!string)
-    return 0;
-
-  G_LOCK (quark_global);
-  quark = quark_from_string (string, FALSE);
-  G_UNLOCK (quark_global);
-
-  return quark;
+  return quark_from_string_locked (string, FALSE);
 }
 
 /**


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