mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-21 08:28:53 +02:00
Reorganize g_type_class_ref()
Moves the first check out of the lock, as it's not required. https://bugzilla.gnome.org/show_bug.cgi?id=585375
This commit is contained in:
committed by
Alexander Larsson
parent
00a4470ad0
commit
5160175656
@@ -2818,24 +2818,21 @@ g_type_class_ref (GType type)
|
|||||||
GType ptype;
|
GType ptype;
|
||||||
|
|
||||||
/* optimize for common code path */
|
/* optimize for common code path */
|
||||||
G_WRITE_LOCK (&type_rw_lock);
|
|
||||||
node = lookup_type_node_I (type);
|
node = lookup_type_node_I (type);
|
||||||
if (node && node->is_classed && node->data &&
|
if (!node || !node->is_classed)
|
||||||
g_atomic_int_get (&node->data->class.init_state) == INITIALIZED)
|
|
||||||
{
|
{
|
||||||
type_data_ref_Wm (node);
|
|
||||||
G_WRITE_UNLOCK (&type_rw_lock);
|
|
||||||
return node->data->class.class;
|
|
||||||
}
|
|
||||||
if (!node || !node->is_classed ||
|
|
||||||
(node->data && NODE_REFCOUNT (node) == 0))
|
|
||||||
{
|
|
||||||
G_WRITE_UNLOCK (&type_rw_lock);
|
|
||||||
g_warning ("cannot retrieve class for invalid (unclassed) type `%s'",
|
g_warning ("cannot retrieve class for invalid (unclassed) type `%s'",
|
||||||
type_descriptive_name_I (type));
|
type_descriptive_name_I (type));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
G_WRITE_LOCK (&type_rw_lock);
|
||||||
type_data_ref_Wm (node);
|
type_data_ref_Wm (node);
|
||||||
|
if (g_atomic_int_get (&node->data->class.init_state) == INITIALIZED)
|
||||||
|
{
|
||||||
|
G_WRITE_UNLOCK (&type_rw_lock);
|
||||||
|
return node->data->class.class;
|
||||||
|
}
|
||||||
ptype = NODE_PARENT_TYPE (node);
|
ptype = NODE_PARENT_TYPE (node);
|
||||||
G_WRITE_UNLOCK (&type_rw_lock);
|
G_WRITE_UNLOCK (&type_rw_lock);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user