From f47a95f4cbb34d79cd14bbe1bef5064326690139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 19 Jun 2014 08:04:01 +0200 Subject: [PATCH] value: Store our fundamental type GTypes in variables Micro optimization to change a function call to a variable access for all our basic types. --- gst/gstvalue.c | 13 ++++++++----- gst/gstvalue.h | 32 ++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/gst/gstvalue.c b/gst/gstvalue.c index a03c5ab1b5..300bab3bb8 100644 --- a/gst/gstvalue.c +++ b/gst/gstvalue.c @@ -5933,17 +5933,20 @@ static GTypeFundamentalInfo _finfo = { }; #define FUNC_VALUE_GET_TYPE(type, name) \ +GType _gst_ ## type ## _type = 0; \ + \ GType gst_ ## type ## _get_type (void) \ { \ - static volatile GType gst_ ## type ## _type = 0; \ + static volatile GType gst_ ## type ## _type = 0; \ \ - if (g_once_init_enter (&gst_ ## type ## _type)) { \ - GType _type; \ + if (g_once_init_enter (&gst_ ## type ## _type)) { \ + GType _type; \ _info.value_table = & _gst_ ## type ## _value_table; \ - _type = g_type_register_fundamental ( \ + _type = g_type_register_fundamental ( \ g_type_fundamental_next (), \ name, &_info, &_finfo, 0); \ - g_once_init_leave(&gst_ ## type ## _type, _type); \ + _gst_ ## type ## _type = _type; \ + g_once_init_leave(&gst_ ## type ## _type, _type); \ } \ \ return gst_ ## type ## _type; \ diff --git a/gst/gstvalue.h b/gst/gstvalue.h index 52baef5ecd..536ae4490f 100644 --- a/gst/gstvalue.h +++ b/gst/gstvalue.h @@ -198,6 +198,8 @@ G_BEGIN_DECLS */ #define GST_VALUE_HOLDS_BITMASK(x) (G_VALUE_HOLDS((x), gst_bitmask_get_type ())) +GST_EXPORT GType _gst_int_range_type; + /** * GST_TYPE_INT_RANGE: * @@ -205,7 +207,9 @@ G_BEGIN_DECLS * * Returns: the #GType of GstIntRange */ -#define GST_TYPE_INT_RANGE gst_int_range_get_type () +#define GST_TYPE_INT_RANGE (_gst_int_range_type) + +GST_EXPORT GType _gst_int64_range_type; /** * GST_TYPE_INT64_RANGE: @@ -214,7 +218,9 @@ G_BEGIN_DECLS * * Returns: the #GType of GstInt64Range */ -#define GST_TYPE_INT64_RANGE gst_int64_range_get_type () +#define GST_TYPE_INT64_RANGE (_gst_int64_range_type) + +GST_EXPORT GType _gst_double_range_type; /** * GST_TYPE_DOUBLE_RANGE: @@ -223,7 +229,9 @@ G_BEGIN_DECLS * * Returns: the #GType of GstIntRange */ -#define GST_TYPE_DOUBLE_RANGE gst_double_range_get_type () +#define GST_TYPE_DOUBLE_RANGE (_gst_double_range_type) + +GST_EXPORT GType _gst_fraction_range_type; /** * GST_TYPE_FRACTION_RANGE: @@ -232,7 +240,9 @@ G_BEGIN_DECLS * * Returns: the #GType of GstFractionRange */ -#define GST_TYPE_FRACTION_RANGE gst_fraction_range_get_type () +#define GST_TYPE_FRACTION_RANGE (_gst_fraction_range_type) + +GST_EXPORT GType _gst_value_list_type; /** * GST_TYPE_LIST: @@ -245,7 +255,9 @@ G_BEGIN_DECLS * * Returns: the #GType of GstValueList (which is not explicitly typed) */ -#define GST_TYPE_LIST gst_value_list_get_type () +#define GST_TYPE_LIST (_gst_value_list_type) + +GST_EXPORT GType _gst_value_array_type; /** * GST_TYPE_ARRAY: @@ -259,7 +271,9 @@ G_BEGIN_DECLS * * Returns: the #GType of GstArrayList (which is not explicitly typed) */ -#define GST_TYPE_ARRAY gst_value_array_get_type () +#define GST_TYPE_ARRAY (_gst_value_array_type) + +GST_EXPORT GType _gst_fraction_type; /** * GST_TYPE_FRACTION: @@ -270,7 +284,9 @@ G_BEGIN_DECLS * Returns: the #GType of GstFraction (which is not explicitly typed) */ -#define GST_TYPE_FRACTION gst_fraction_get_type () +#define GST_TYPE_FRACTION (_gst_fraction_type) + +GST_EXPORT GType _gst_bitmask_type; /** * GST_TYPE_BITMASK: @@ -280,7 +296,7 @@ G_BEGIN_DECLS * Returns: the #GType of GstBitmask (which is not explicitly typed) */ -#define GST_TYPE_BITMASK gst_bitmask_get_type () +#define GST_TYPE_BITMASK (_gst_bitmask_type) /** * GST_TYPE_G_THREAD: