[glib/gobject-performance] Remove more read locks usage
- From: Benjamin Otte <otte src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib/gobject-performance] Remove more read locks usage
- Date: Thu, 24 Sep 2009 13:10:33 +0000 (UTC)
commit 67d82ae07788efe56fe4e4bcb2e80fc0e0421002
Author: Benjamin Otte <otte gnome org>
Date: Thu Sep 24 15:04:20 2009 +0200
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.
gobject/gtype.c | 15 ++++-----------
1 files changed, 4 insertions(+), 11 deletions(-)
---
diff --git a/gobject/gtype.c b/gobject/gtype.c
index ef2cc99..a89d739 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -2954,7 +2954,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;
@@ -3179,12 +3179,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;
}
@@ -4105,14 +4103,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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]