[glib/gobject-performance] Pass the TypeNode to type_data_last_unref_Wm()



commit 7878334ce4e0897ad8e171e0b17a20c1a1996cfa
Author: Edward Hervey <bilboed bilboed com>
Date:   Thu Sep 24 10:16:48 2009 +0200

    Pass the TypeNode to type_data_last_unref_Wm()
    
    Previously the GType was looked up just for calling the function
    Also moves the unref functions together in the code.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=585375

 gobject/gtype.c |   57 ++++++++++++++++++++++++++----------------------------
 1 files changed, 27 insertions(+), 30 deletions(-)
---
diff --git a/gobject/gtype.c b/gobject/gtype.c
index 32cd03a..307f8ef 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -187,7 +187,7 @@ static	      void			type_data_make_W		(TypeNode		*node,
 static inline void			type_data_ref_Wm		(TypeNode		*node);
 static inline void			type_data_unref_WmREC		(TypeNode		*node,
 									 gboolean		 uncached);
-static void				type_data_last_unref_Wm		(GType			 type,
+static void				type_data_last_unref_Wm		(TypeNode *              node,
 									 gboolean		 uncached);
 static inline gpointer			type_get_qdata_L		(TypeNode		*node,
 									 GQuark			 quark);
@@ -1199,30 +1199,6 @@ type_data_ref_Wm (TypeNode *node)
     }
 }
 
-static inline void
-type_data_unref_WmREC (TypeNode *node,
-                       gboolean  uncached)
-{
-  g_assert (node->data && node->ref_count);
-  if (node->ref_count > 1)
-    node->ref_count -= 1;
-  else
-    {
-      GType node_type = NODE_TYPE (node);
-      if (!node->plugin)
-	{
-	  g_warning ("static type `%s' unreferenced too often",
-		     NODE_NAME (node));
-	  return;
-	}
-      G_WRITE_UNLOCK (&type_rw_lock);
-      g_static_rec_mutex_lock (&class_init_rec_mutex); /* required locking order: 1) class_init_rec_mutex, 2) type_rw_lock */
-      G_WRITE_LOCK (&type_rw_lock);
-      type_data_last_unref_Wm (node_type, uncached);
-      g_static_rec_mutex_unlock (&class_init_rec_mutex);
-    }
-}
-
 static gboolean
 iface_node_has_available_offset_L (TypeNode *iface_node,
 				   int offset,
@@ -2270,17 +2246,15 @@ type_data_finalize_class_U (TypeNode  *node,
 }
 
 static void
-type_data_last_unref_Wm (GType    type,
-			 gboolean uncached)
+type_data_last_unref_Wm (TypeNode *node,
+			 gboolean  uncached)
 {
-  TypeNode *node = lookup_type_node_I (type);
-  
   g_return_if_fail (node != NULL && node->plugin != NULL);
   
   if (!node->data || node->ref_count == 0)
     {
       g_warning ("cannot drop last reference to unreferenced type `%s'",
-		 type_descriptive_name_I (type));
+		 NODE_NAME (node));
       return;
     }
 
@@ -2368,6 +2342,29 @@ type_data_last_unref_Wm (GType    type,
     }
 }
 
+static inline void
+type_data_unref_WmREC (TypeNode *node,
+                       gboolean  uncached)
+{
+  g_assert (node->data && node->ref_count);
+  if (node->ref_count > 1)
+    node->ref_count -= 1;
+  else
+    {
+      if (!node->plugin)
+	{
+	  g_warning ("static type `%s' unreferenced too often",
+		     NODE_NAME (node));
+	  return;
+	}
+      G_WRITE_UNLOCK (&type_rw_lock);
+      g_static_rec_mutex_lock (&class_init_rec_mutex); /* required locking order: 1) class_init_rec_mutex, 2) type_rw_lock */
+      G_WRITE_LOCK (&type_rw_lock);
+      type_data_last_unref_Wm (node, uncached);
+      g_static_rec_mutex_unlock (&class_init_rec_mutex);
+    }
+}
+
 /**
  * g_type_add_class_cache_func:
  * @cache_data: data to be passed to @cache_func



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]