value: Store our fundamental type GTypes in variables
authorSebastian Dröge <sebastian@centricular.com>
Thu, 19 Jun 2014 06:04:01 +0000 (08:04 +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.

gst/gstvalue.c
gst/gstvalue.h

index a03c5ab..300bab3 100644 (file)
@@ -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;                                 \
index 52baef5..536ae44 100644 (file)
@@ -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: