Commit db1e4422 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

gst: Store more basic type GTypes in variables

Micro optimization to change a function call to a variable access
for all our basic types.
parent f47a95f4
......@@ -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 ();
......
......@@ -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
......
......@@ -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);
......
......@@ -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))
......
......@@ -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
......
......@@ -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))
......
......@@ -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 ();
}
......@@ -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);
......
......@@ -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 ();
}
......@@ -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;
......
......@@ -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
......
......@@ -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))
......
......@@ -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
{
......
......@@ -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))
......
......@@ -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,
......
......@@ -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))
/**
......
......@@ -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 ();
}
......@@ -30,8 +30,11 @@
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment