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
This commit is contained in:
Natanael Copa 2016-07-06 16:23:48 +02:00 committed by Philip Withnall
parent a66fc8e3a9
commit 2f07630b43

View File

@ -190,6 +190,22 @@ quark_from_string (const gchar *string,
return quark; 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: * g_quark_from_string:
* @string: (nullable): a string * @string: (nullable): a string
@ -203,16 +219,7 @@ quark_from_string (const gchar *string,
GQuark GQuark
g_quark_from_string (const gchar *string) g_quark_from_string (const gchar *string)
{ {
GQuark quark; return quark_from_string_locked (string, TRUE);
if (!string)
return 0;
G_LOCK (quark_global);
quark = quark_from_string (string, TRUE);
G_UNLOCK (quark_global);
return quark;
} }
/** /**
@ -237,16 +244,7 @@ g_quark_from_string (const gchar *string)
GQuark GQuark
g_quark_from_static_string (const gchar *string) g_quark_from_static_string (const gchar *string)
{ {
GQuark quark; return quark_from_string_locked (string, FALSE);
if (!string)
return 0;
G_LOCK (quark_global);
quark = quark_from_string (string, FALSE);
G_UNLOCK (quark_global);
return quark;
} }
/** /**