gst: Store more basic type GTypes in variables
authorSebastian Dröge <sebastian@centricular.com>
Thu, 19 Jun 2014 06:05:03 +0000 (08:05 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Thu, 19 Jun 2014 06:06:55 +0000 (08:06 +0200)
Micro optimization to change a function call to a variable access
for all our basic types.

18 files changed:
gst/gst.c
gst/gst_private.h
gst/gstallocator.c
gst/gstcapsfeatures.h
gst/gstcontext.c
gst/gstcontext.h
gst/gstdatetime.c
gst/gstdatetime.h
gst/gstmemory.c
gst/gstmemory.h
gst/gstmessage.c
gst/gstmessage.h
gst/gstquery.c
gst/gstquery.h
gst/gsttaglist.c
gst/gsttaglist.h
gst/gsttoc.c
gst/gsttoc.h

index 5cc7abeaa6e95b6ceaa6d0255a2e3d44575e1a61..f160772b13eed1060083950c06df13fad8797ba4 100644 (file)
--- a/gst/gst.c
+++ b/gst/gst.c
@@ -566,6 +566,7 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
 
   _priv_gst_mini_object_initialize ();
   _priv_gst_quarks_initialize ();
+  _priv_gst_allocator_initialize ();
   _priv_gst_memory_initialize ();
   _priv_gst_format_initialize ();
   _priv_gst_query_initialize ();
@@ -573,6 +574,7 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
   _priv_gst_caps_initialize ();
   _priv_gst_caps_features_initialize ();
   _priv_gst_meta_initialize ();
+  _priv_gst_message_initialize ();
 
   g_type_class_ref (gst_object_get_type ());
   g_type_class_ref (gst_pad_get_type ());
@@ -670,11 +672,12 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
 
   _priv_gst_event_initialize ();
   _priv_gst_buffer_initialize ();
-  _priv_gst_message_initialize ();
   _priv_gst_buffer_list_initialize ();
   _priv_gst_sample_initialize ();
-  _priv_gst_value_initialize ();
   _priv_gst_context_initialize ();
+  _priv_gst_date_time_initialize ();
+  _priv_gst_toc_initialize ();
+  _priv_gst_value_initialize ();
 
   g_type_class_ref (gst_param_spec_fraction_get_type ());
   _priv_gst_tag_initialize ();
index d610560b4e6cb7eaf61663e9854e3728096eddf2..7d0fe15abece3c9c020d4302b185cdddbf4d6b67 100644 (file)
@@ -104,6 +104,8 @@ G_GNUC_INTERNAL  gboolean _priv_gst_in_valgrind (void);
 /* init functions called from gst_init(). */
 G_GNUC_INTERNAL  void  _priv_gst_quarks_initialize (void);
 G_GNUC_INTERNAL  void  _priv_gst_mini_object_initialize (void);
+G_GNUC_INTERNAL  void  _priv_gst_memory_initialize (void);
+G_GNUC_INTERNAL  void  _priv_gst_allocator_initialize (void);
 G_GNUC_INTERNAL  void  _priv_gst_buffer_initialize (void);
 G_GNUC_INTERNAL  void  _priv_gst_buffer_list_initialize (void);
 G_GNUC_INTERNAL  void  _priv_gst_structure_initialize (void);
@@ -121,6 +123,8 @@ G_GNUC_INTERNAL  void  _priv_gst_tag_initialize (void);
 G_GNUC_INTERNAL  void  _priv_gst_value_initialize (void);
 G_GNUC_INTERNAL  void  _priv_gst_debug_init (void);
 G_GNUC_INTERNAL  void  _priv_gst_context_initialize (void);
+G_GNUC_INTERNAL  void  _priv_gst_toc_initialize (void);
+G_GNUC_INTERNAL  void  _priv_gst_date_time_initialize (void);
 
 /* Private registry functions */
 G_GNUC_INTERNAL
index 6363ba547793b0e29079558279895d3bf650b140..cbcb1e487172fee72035ea9d0f814667c33d4989 100644 (file)
@@ -569,7 +569,7 @@ gst_allocator_sysmem_init (GstAllocatorSysmem * allocator)
 }
 
 void
-_priv_gst_memory_initialize (void)
+_priv_gst_allocator_initialize (void)
 {
   g_rw_lock_init (&lock);
   allocators = g_hash_table_new (g_str_hash, g_str_equal);
index 62d9e3c439a06c6ca4a1fc307480fef79167c805..441e1a11ad63a0719777b37c14439dcf33dfaf57 100644 (file)
@@ -28,7 +28,9 @@ G_BEGIN_DECLS
 
 typedef struct _GstCapsFeatures GstCapsFeatures;
 
-#define GST_TYPE_CAPS_FEATURES (gst_caps_features_get_type ())
+GST_EXPORT GType _gst_caps_features_type;
+
+#define GST_TYPE_CAPS_FEATURES (_gst_caps_features_type)
 #define GST_IS_CAPS_FEATURES(object)       (gst_is_caps_features(object))
 #define GST_CAPS_FEATURES_CAST(object)     ((GstCapsFeatures *)(object))
 #define GST_CAPS_FEATURES(object)          (GST_CAPS_FEATURES_CAST(object))
index 1cc3f3f96414a4b588eb1f348af6e0df81992dcd..b535574ec7dafb2875b4806933679d79f7f4fe43 100644 (file)
@@ -68,7 +68,7 @@ struct _GstContext
 
 #define GST_CONTEXT_STRUCTURE(c)  (((GstContext *)(c))->structure)
 
-static GType _gst_context_type = 0;
+GType _gst_context_type = 0;
 GST_DEFINE_MINI_OBJECT_TYPE (GstContext, gst_context);
 
 void
index a0aa8705ea78c3c51893ee14889817b6787f2095..0883f0da8bd1b42394f95b58e9d3335c1fd82afa 100644 (file)
@@ -31,7 +31,9 @@ typedef struct _GstContext GstContext;
 #include <gst/gstminiobject.h>
 #include <gst/gststructure.h>
 
-#define GST_TYPE_CONTEXT                         (gst_context_get_type())
+GST_EXPORT GType _gst_context_type;
+
+#define GST_TYPE_CONTEXT                         (_gst_context_type)
 #define GST_IS_CONTEXT(obj)                      (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_CONTEXT))
 #define GST_CONTEXT_CAST(obj)                    ((GstContext*)(obj))
 #define GST_CONTEXT(obj)                         (GST_CONTEXT_CAST(obj))
index 94ae2621d621104b8998c0ec4e7179d64e80b1f5..d21cca467e5608a9e194be68964b644bc80dbac9 100644 (file)
@@ -63,6 +63,7 @@ struct _GstDateTime
   GstDateTimeFields fields;
 };
 
+GType _gst_date_time_type = 0;
 GST_DEFINE_MINI_OBJECT_TYPE (GstDateTime, gst_date_time);
 
 static void gst_date_time_free (GstDateTime * datetime);
@@ -909,3 +910,9 @@ gst_date_time_unref (GstDateTime * datetime)
 {
   gst_mini_object_unref (GST_MINI_OBJECT_CAST (datetime));
 }
+
+void
+_priv_gst_date_time_initialize (void)
+{
+  _gst_date_time_type = gst_date_time_get_type ();
+}
index 879ab4a2a0a7b4a81bc5c0e4d6a948a96d0259af..251dce110703b45b8bc1a3a1c622002d4644b976 100644 (file)
@@ -36,6 +36,8 @@ G_BEGIN_DECLS
  */
 typedef struct _GstDateTime GstDateTime;
 
+GST_EXPORT GType _gst_date_time_type;
+
 /**
  * GST_TYPE_DATE_TIME:
  *
@@ -44,7 +46,7 @@ typedef struct _GstDateTime GstDateTime;
  * Returns: the #GType of GstDateTime
  */
 
-#define GST_TYPE_DATE_TIME gst_date_time_get_type()
+#define GST_TYPE_DATE_TIME (_gst_date_time_type)
 
 GType           gst_date_time_get_type (void);
 
index d5811f6817bd25630e0e35a5e5905ce6b1ecc2f1..c29fccddb7f5865ea72f1001f5b00cb73e1c708c 100644 (file)
@@ -69,6 +69,7 @@
 #include "gst_private.h"
 #include "gstmemory.h"
 
+GType _gst_memory_type = 0;
 GST_DEFINE_MINI_OBJECT_TYPE (GstMemory, gst_memory);
 
 static GstMemory *
@@ -425,3 +426,9 @@ gst_memory_is_span (GstMemory * mem1, GstMemory * mem2, gsize * offset)
 
   return TRUE;
 }
+
+void
+_priv_gst_memory_initialize (void)
+{
+  _gst_memory_type = gst_memory_get_type ();
+}
index b5180ca3b102308b0198d1cb0580ada7acff80c6..4819e2a16bc135757ae86906df52b6c7ddc4af84 100644 (file)
@@ -29,7 +29,8 @@
 
 G_BEGIN_DECLS
 
-#define GST_TYPE_MEMORY (gst_memory_get_type())
+GST_EXPORT GType _gst_memory_type;
+#define GST_TYPE_MEMORY (_gst_memory_type)
 GType gst_memory_get_type(void);
 
 typedef struct _GstMemory GstMemory;
index 9a790d381b49a725fe22e41a350f416429feb517..a0254cc58721fdac4b711ad3f9dc1ad3f6d8656e 100644 (file)
@@ -108,7 +108,7 @@ static GstMessageQuarks message_quarks[] = {
   {0, NULL, 0}
 };
 
-static GType _gst_message_type = 0;
+GType _gst_message_type = 0;
 GST_DEFINE_MINI_OBJECT_TYPE (GstMessage, gst_message);
 
 void
index 72b4260064694588706ed0b99b58433bc22d53cd..7433edc6a6afef5d20b6b08cc8cba330abdbc740 100644 (file)
@@ -165,7 +165,9 @@ typedef enum
 #include <gst/gsttoc.h>
 #include <gst/gstdevice.h>
 
-#define GST_TYPE_MESSAGE                         (gst_message_get_type())
+GST_EXPORT GType _gst_message_type;
+
+#define GST_TYPE_MESSAGE                         (_gst_message_type)
 #define GST_IS_MESSAGE(obj)                      (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_MESSAGE))
 #define GST_MESSAGE_CAST(obj)                    ((GstMessage*)(obj))
 #define GST_MESSAGE(obj)                         (GST_MESSAGE_CAST(obj))
index 076b8dca9cdba7c12a74850c6e1dccdc68123876..78a04fa7adcf123343690ea07d0d792faf625591 100644 (file)
@@ -65,7 +65,7 @@
 GST_DEBUG_CATEGORY_STATIC (gst_query_debug);
 #define GST_CAT_DEFAULT gst_query_debug
 
-static GType _gst_query_type = 0;
+GType _gst_query_type = 0;
 
 typedef struct
 {
index cee72b25455ac2c925ef197041e8291a6d2b711c..3750a19a14d71667a15401e6b039b331fc540453 100644 (file)
@@ -132,7 +132,9 @@ typedef enum {
 } GstQueryType;
 #undef FLAG
 
-#define GST_TYPE_QUERY                         (gst_query_get_type())
+GST_EXPORT GType _gst_query_type;
+
+#define GST_TYPE_QUERY                         (_gst_query_type)
 #define GST_IS_QUERY(obj)                      (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_QUERY))
 #define GST_QUERY_CAST(obj)                    ((GstQuery*)(obj))
 #define GST_QUERY(obj)                         (GST_QUERY_CAST(obj))
index 0eac36d802f7292089611b8569d0bb555afcfeaa..1d1ee5891294c27558ed934779284f337f308997 100644 (file)
@@ -84,6 +84,7 @@ static GMutex __tag_mutex;
 /* tags hash table: maps tag name string => GstTagInfo */
 static GHashTable *__tags;
 
+GType _gst_tag_list_type = 0;
 GST_DEFINE_MINI_OBJECT_TYPE (GstTagList, gst_tag_list);
 
 static void __gst_tag_list_free (GstTagList * list);
@@ -98,6 +99,8 @@ _priv_gst_tag_initialize (void)
 {
   g_mutex_init (&__tag_mutex);
 
+  _gst_tag_list_type = gst_tag_list_get_type ();
+
   __tags = g_hash_table_new (g_str_hash, g_str_equal);
   gst_tag_register_static (GST_TAG_TITLE, GST_TAG_FLAG_META,
       G_TYPE_STRING,
index 80edea144dc7c1ec2490d348202959d56b506e8f..42f944bb1236d657081f4f2f4cfae31152779672 100644 (file)
@@ -154,8 +154,10 @@ struct _GstTagList {
   GstMiniObject mini_object;
 };
 
+GST_EXPORT GType _gst_tag_list_type;
+
 #define GST_TAG_LIST(x)       ((GstTagList *) (x))
-#define GST_TYPE_TAG_LIST     (gst_tag_list_get_type ())
+#define GST_TYPE_TAG_LIST     (_gst_tag_list_type)
 #define GST_IS_TAG_LIST(obj)  (GST_IS_MINI_OBJECT_TYPE((obj), GST_TYPE_TAG_LIST))
 
 /**
index 546a774d1d6c3a931fd19c84dac28ca897671535..bee13cb2ac49c1079ac99724d53e39c4576cabda 100644 (file)
@@ -116,6 +116,9 @@ static void gst_toc_free (GstToc * toc);
 static GstTocEntry *gst_toc_entry_copy (const GstTocEntry * toc);
 static void gst_toc_entry_free (GstTocEntry * toc);
 
+GType _gst_toc_type = 0;
+GType _gst_toc_entry_type = 0;
+
 GST_DEFINE_MINI_OBJECT_TYPE (GstToc, gst_toc);
 GST_DEFINE_MINI_OBJECT_TYPE (GstTocEntry, gst_toc_entry);
 
@@ -820,3 +823,10 @@ gst_toc_dump (GstToc * toc)
   gst_toc_dump_entries (toc->entries, 2);
 #endif
 }
+
+void
+_priv_gst_toc_initialize (void)
+{
+  _gst_toc_type = gst_toc_get_type ();
+  _gst_toc_entry_type = gst_toc_entry_get_type ();
+}
index a9815d8e4ab4c48e3d7b020a73fbf52981a0a032..39469c188508d71f70fb8315ff65e65f27426e6f 100644 (file)
 
 G_BEGIN_DECLS
 
-#define GST_TYPE_TOC (gst_toc_get_type ())
-#define GST_TYPE_TOC_ENTRY (gst_toc_entry_get_type ())
+GST_EXPORT GType _gst_toc_type;
+GST_EXPORT GType _gst_toc_entry_type;
+
+#define GST_TYPE_TOC (_gst_toc_type)
+#define GST_TYPE_TOC_ENTRY (_gst_toc_entry_type)
 
 typedef struct _GstTocEntry GstTocEntry;
 typedef struct _GstToc GstToc;