[seed] Switch GObject reference to the JS ref to use g_ob



commit f0c46d887da7004fabc23a6368a9900ecbd76153
Author: Robert Carr <racarr mireia (none)>
Date:   Mon Mar 2 21:49:16 2009 -0500

    Switch GObject reference to the JS ref to use g_object_set_qdata, low hanging optimization
---
 libseed/seed-engine.c |    5 ++++-
 libseed/seed-types.c  |    4 ++--
 libseed/seed-types.h  |    2 ++
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/libseed/seed-engine.c b/libseed/seed-engine.c
index 315f640..c2903a6 100644
--- a/libseed/seed-engine.c
+++ b/libseed/seed-engine.c
@@ -35,6 +35,8 @@ gchar *glib_message = 0;
 
 GIBaseInfo *base_info_info = 0;
 
+GQuark js_ref_quark;
+
 guint seed_debug_flags = 0;	/* global seed debug flag */
 
 #ifdef SEED_ENABLE_DEBUG
@@ -1455,6 +1457,7 @@ seed_init (gint * argc, gchar *** argv)
 
   qname = g_quark_from_static_string ("js-type");
   qprototype = g_quark_from_static_string ("js-prototype");
+  js_ref_quark = g_quark_from_static_string ("js-ref");
 
   eng = (SeedEngine *) g_malloc (sizeof (SeedEngine));
 
@@ -1512,6 +1515,6 @@ seed_init (gint * argc, gchar *** argv)
 
   base_info_info =
     g_irepository_find_by_name (0, "GIRepository", "IBaseInfo");
-
+  
   return eng;
 }
diff --git a/libseed/seed-types.c b/libseed/seed-types.c
index 53fcfe7..cb17b30 100644
--- a/libseed/seed-types.c
+++ b/libseed/seed-types.c
@@ -68,7 +68,7 @@ seed_wrap_object (JSContextRef ctx, GObject * object)
 
   type = G_OBJECT_TYPE (object);
 
-  user_data = (JSValueRef) g_object_get_data (object, "js-ref");
+  user_data = (JSValueRef) g_object_get_qdata (object, js_ref_quark);
 
   if (user_data)
     return user_data;
@@ -89,7 +89,7 @@ seed_wrap_object (JSContextRef ctx, GObject * object)
       g_assert_not_reached ();
     }
 
-  g_object_set_data_full (object, "js-ref", (gpointer) js_ref,
+  g_object_set_qdata_full (object, js_ref_quark, (gpointer) js_ref,
 			  seed_gobject_destroyed);
 
   JSValueProtect (eng->context, js_ref);
diff --git a/libseed/seed-types.h b/libseed/seed-types.h
index bc97f8f..6af369a 100644
--- a/libseed/seed-types.h
+++ b/libseed/seed-types.h
@@ -36,6 +36,8 @@
 
 #include "seed-private.h"
 
+extern GQuark js_ref_quark;
+
 JSValueRef seed_value_from_gvalue (JSContextRef ctx,
 				   GValue * gval, JSValueRef * exception);
 



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