[glib/gobject-performance] Reorganize g_type_class_ref()
- From: Benjamin Otte <otte src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib/gobject-performance] Reorganize g_type_class_ref()
- Date: Thu, 24 Sep 2009 11:30:55 +0000 (UTC)
commit 74349acc6a9586b590b2c833515cb4230f5a7805
Author: Edward Hervey <bilboed bilboed com>
Date: Thu Sep 24 12:29:25 2009 +0200
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
gobject/gtype.c | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
---
diff --git a/gobject/gtype.c b/gobject/gtype.c
index be08719..b5d44f0 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -2816,24 +2816,21 @@ g_type_class_ref (GType type)
GType ptype;
/* optimize for common code path */
- G_WRITE_LOCK (&type_rw_lock);
node = lookup_type_node_I (type);
- if (node && node->is_classed && node->data &&
- 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))
+ if (!node || !node->is_classed)
{
- G_WRITE_UNLOCK (&type_rw_lock);
g_warning ("cannot retrieve class for invalid (unclassed) type `%s'",
type_descriptive_name_I (type));
return NULL;
}
+
+ G_WRITE_LOCK (&type_rw_lock);
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);
G_WRITE_UNLOCK (&type_rw_lock);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]