diff options
author | Benjamin Otte <otte@gnome.org> | 2009-09-24 15:04:20 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2009-11-30 20:52:33 +0100 |
commit | f0f32a7ef0f7ae8cdd2aa2992d2e116dd7b602fe (patch) | |
tree | 66a16cedc417917a5b7a34365eac7dde99065371 /gobject | |
parent | 5cac5c828b9d56ed0b1932deb7364d6ba926eb96 (diff) |
Remove more read locks usage
g_type_default_interface_peek() and g_type_value_table_peek() don't need
to acquire read locks anymore when they test the refcount instead of
node->data.
Diffstat (limited to 'gobject')
-rw-r--r-- | gobject/gtype.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/gobject/gtype.c b/gobject/gtype.c index d0f1c99be..cc3b9dfc2 100644 --- a/gobject/gtype.c +++ b/gobject/gtype.c @@ -2950,7 +2950,7 @@ g_type_class_peek (GType type) gpointer class; node = lookup_type_node_I (type); - if (node && node->is_classed && NODE_REFCOUNT (node) > 0 && + if (node && node->is_classed && NODE_REFCOUNT (node) && g_atomic_int_get (&node->data->class.init_state) == INITIALIZED) /* ref_count _may_ be 0 */ class = node->data->class.class; @@ -3175,12 +3175,10 @@ g_type_default_interface_peek (GType g_type) gpointer vtable; node = lookup_type_node_I (g_type); - G_READ_LOCK (&type_rw_lock); - if (node && NODE_IS_IFACE (node) && node->data && node->data->iface.dflt_vtable) + if (node && NODE_IS_IFACE (node) && NODE_REFCOUNT (node)) vtable = node->data->iface.dflt_vtable; else vtable = NULL; - G_READ_UNLOCK (&type_rw_lock); return vtable; } @@ -4101,14 +4099,9 @@ g_type_value_table_peek (GType type) GTypeValueTable *vtable = NULL; TypeNode *node = lookup_type_node_I (type); gboolean has_refed_data, has_table; - TypeData *data; - /* speed up common code path, we're not 100% safe here, - * but we should only get called with referenced types anyway - */ - data = node ? node->data : NULL; - if (node && node->mutatable_check_cache) - return data->common.value_table; + if (node && NODE_REFCOUNT (node) && node->mutatable_check_cache) + return node->data->common.value_table; G_READ_LOCK (&type_rw_lock); |