optimisation : Use g_object_newv where possible.
authorEdward Hervey <bilboed@bilboed.com>
Wed, 28 Oct 2009 08:26:32 +0000 (09:26 +0100)
committerEdward Hervey <bilboed@bilboed.com>
Wed, 28 Oct 2009 08:31:17 +0000 (09:31 +0100)
This avoids:
* triple-checking for the GType when type-checking is enabled (see #597260)
* Avoids going through an expensive no-argument checking which landed in
  glib-2.22
* Avoids going through 2 extrac functions (g_object_new -> g_object_new_valist)

19 files changed:
gst/gstbus.c
gst/gstelementfactory.c
gst/gstindex.c
gst/gstindexfactory.c
gst/gstobject.c
gst/gstplugin.c
gst/gstpluginloader.c
gst/gstregistry.c
gst/gstregistrychunks.c
gst/gsttask.c
gst/gsttaskpool.c
gst/gsttypefind.c
gst/gstxml.c
libs/gst/base/gstadapter.c
libs/gst/base/gstcollectpads.c
libs/gst/base/gstdataqueue.c
libs/gst/controller/gstcontroller.c
libs/gst/controller/gstinterpolationcontrolsource.c
libs/gst/controller/gstlfocontrolsource.c

index 6088b81..2df4cb9 100644 (file)
@@ -273,7 +273,7 @@ gst_bus_new (void)
 {
   GstBus *result;
 
-  result = g_object_new (gst_bus_get_type (), NULL);
+  result = g_object_newv (gst_bus_get_type (), 0, NULL);
   GST_DEBUG_OBJECT (result, "created new bus");
 
   return result;
index 8c47a5a..0cdb5ff 100644 (file)
@@ -281,7 +281,8 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
   }
 
   factory =
-      GST_ELEMENT_FACTORY_CAST (g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL));
+      GST_ELEMENT_FACTORY_CAST (g_object_newv (GST_TYPE_ELEMENT_FACTORY, 0,
+          NULL));
   gst_plugin_feature_set_name (GST_PLUGIN_FEATURE_CAST (factory), name);
   GST_LOG_OBJECT (factory, "Created new elementfactory for type %s",
       g_type_name (type));
@@ -405,7 +406,7 @@ gst_element_factory_create (GstElementFactory * factory, const gchar * name)
     goto no_type;
 
   /* create an instance of the element, cast so we don't assert on NULL */
-  element = GST_ELEMENT_CAST (g_object_new (factory->type, NULL));
+  element = GST_ELEMENT_CAST (g_object_newv (factory->type, 0, NULL));
   if (G_UNLIKELY (element == NULL))
     goto no_element;
 
index 0b3391f..0a70c3b 100644 (file)
@@ -283,7 +283,7 @@ gst_index_new (void)
 {
   GstIndex *index;
 
-  index = g_object_new (gst_index_get_type (), NULL);
+  index = g_object_newv (gst_index_get_type (), 0, NULL);
 
   return index;
 }
index 403144d..97083d7 100644 (file)
@@ -87,7 +87,7 @@ gst_index_factory_new (const gchar * name, const gchar * longdesc, GType type)
   GstIndexFactory *factory;
 
   g_return_val_if_fail (name != NULL, NULL);
-  factory = GST_INDEX_FACTORY (g_object_new (GST_TYPE_INDEX_FACTORY, NULL));
+  factory = GST_INDEX_FACTORY (g_object_newv (GST_TYPE_INDEX_FACTORY, 0, NULL));
 
   GST_PLUGIN_FEATURE_NAME (factory) = g_strdup (name);
   if (factory->longdesc)
@@ -160,7 +160,7 @@ gst_index_factory_create (GstIndexFactory * factory)
   if (newfactory == NULL)
     return NULL;
 
-  new = GST_INDEX (g_object_new (newfactory->type, NULL));
+  new = GST_INDEX (g_object_newv (newfactory->type, 0, NULL));
 
   gst_object_unref (newfactory);
 
index 000b347..52b3fb1 100644 (file)
@@ -246,7 +246,7 @@ gst_object_class_init (GstObjectClass * klass)
   klass->lock = g_new0 (GStaticRecMutex, 1);
   g_static_rec_mutex_init (klass->lock);
 
-  klass->signal_object = g_object_new (gst_signal_object_get_type (), NULL);
+  klass->signal_object = g_object_newv (gst_signal_object_get_type (), 0, NULL);
 
   /* see the comments at gst_object_dispatch_properties_changed */
   gobject_class->dispatch_properties_changed
index 0d29ce3..609a789 100644 (file)
@@ -245,7 +245,7 @@ gst_plugin_register_static (gint major_version, gint minor_version,
   g_return_val_if_fail (_gst_plugin_inited != FALSE, FALSE);
 
   GST_LOG ("attempting to load static plugin \"%s\" now...", name);
-  plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
+  plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
   if (gst_plugin_register_func (plugin, &desc, NULL) != NULL) {
     GST_INFO ("registered static plugin \"%s\"", name);
     res = gst_default_registry_add_plugin (plugin);
@@ -314,7 +314,7 @@ gst_plugin_register_static_full (gint major_version, gint minor_version,
   g_return_val_if_fail (_gst_plugin_inited != FALSE, FALSE);
 
   GST_LOG ("attempting to load static plugin \"%s\" now...", name);
-  plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
+  plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
   if (gst_plugin_register_func (plugin, &desc, user_data) != NULL) {
     GST_INFO ("registered static plugin \"%s\"", name);
     res = gst_default_registry_add_plugin (plugin);
@@ -593,7 +593,7 @@ gst_plugin_load_file (const gchar * filename, GError ** error)
   }
 
   if (new_plugin) {
-    plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
+    plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
     plugin->file_mtime = file_status.st_mtime;
     plugin->file_size = file_status.st_size;
     plugin->filename = g_strdup (filename);
index f69c1e3..36b796a 100644 (file)
@@ -320,7 +320,7 @@ static void
 plugin_loader_create_blacklist_plugin (GstPluginLoader * l,
     PendingPluginEntry * entry)
 {
-  GstPlugin *plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
+  GstPlugin *plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
 
   plugin->filename = g_strdup (entry->filename);
   plugin->file_mtime = entry->file_mtime;
index 9e4efd2..56f4744 100644 (file)
@@ -298,7 +298,7 @@ gst_registry_get_default (void)
 
   g_static_mutex_lock (&_gst_registry_mutex);
   if (G_UNLIKELY (!_gst_registry_default)) {
-    _gst_registry_default = g_object_new (GST_TYPE_REGISTRY, NULL);
+    _gst_registry_default = g_object_newv (GST_TYPE_REGISTRY, 0, NULL);
     gst_object_ref_sink (GST_OBJECT_CAST (_gst_registry_default));
   }
   registry = _gst_registry_default;
index d81542b..e1e7dec 100644 (file)
@@ -514,7 +514,7 @@ gst_registry_chunks_load_feature (GstRegistry * registry, gchar ** in,
     g_free (type_name);
     return FALSE;
   }
-  if (G_UNLIKELY ((feature = g_object_new (type, NULL)) == NULL)) {
+  if (G_UNLIKELY ((feature = g_object_newv (type, 0, NULL)) == NULL)) {
     GST_ERROR ("Can't create feature from type");
     g_free (type_name);
     return FALSE;
@@ -728,7 +728,7 @@ _priv_gst_registry_chunks_load_plugin (GstRegistry * registry, gchar ** in,
       *in);
   unpack_element (*in, pe, GstRegistryChunkPluginElement, end, fail);
 
-  plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
+  plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
 
   /* TODO: also set GST_PLUGIN_FLAG_CONST */
   plugin->flags |= GST_PLUGIN_FLAG_CACHED;
index b376b0b..e55fa58 100644 (file)
@@ -323,7 +323,7 @@ gst_task_create (GstTaskFunction func, gpointer data)
 {
   GstTask *task;
 
-  task = g_object_new (GST_TYPE_TASK, NULL);
+  task = g_object_newv (GST_TYPE_TASK, 0, NULL);
   task->func = func;
   task->data = data;
 
index 9ca2ffa..e065fca 100644 (file)
@@ -162,7 +162,7 @@ gst_task_pool_new (void)
 {
   GstTaskPool *pool;
 
-  pool = g_object_new (GST_TYPE_TASK_POOL, NULL);
+  pool = g_object_newv (GST_TYPE_TASK_POOL, 0, NULL);
 
   return pool;
 }
index 756e882..8f43b26 100644 (file)
@@ -81,7 +81,7 @@ gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank,
 
   GST_INFO ("registering typefind function for %s", name);
 
-  factory = g_object_new (GST_TYPE_TYPE_FIND_FACTORY, NULL);
+  factory = g_object_newv (GST_TYPE_TYPE_FIND_FACTORY, 0, NULL);
   GST_DEBUG_OBJECT (factory, "using new typefind factory for %s", name);
   g_assert (GST_IS_TYPE_FIND_FACTORY (factory));
 
index 1d7185c..fd3daf1 100644 (file)
@@ -115,7 +115,7 @@ gst_xml_dispose (GObject * object)
 GstXML *
 gst_xml_new (void)
 {
-  return GST_XML (g_object_new (GST_TYPE_XML, NULL));
+  return GST_XML (g_object_newv (GST_TYPE_XML, 0, NULL));
 }
 
 /**
index d326556..ae864d2 100644 (file)
@@ -192,7 +192,7 @@ gst_adapter_finalize (GObject * object)
 GstAdapter *
 gst_adapter_new (void)
 {
-  return g_object_new (GST_TYPE_ADAPTER, NULL);
+  return g_object_newv (GST_TYPE_ADAPTER, 0, NULL);
 }
 
 /**
index 8f75e7e..77a1ba3 100644 (file)
@@ -164,7 +164,7 @@ gst_collect_pads_new (void)
 {
   GstCollectPads *newcoll;
 
-  newcoll = g_object_new (GST_TYPE_COLLECT_PADS, NULL);
+  newcoll = g_object_newv (GST_TYPE_COLLECT_PADS, 0, NULL);
 
   return newcoll;
 }
index 5dbd420..b408b42 100644 (file)
@@ -206,7 +206,7 @@ gst_data_queue_new_full (GstDataQueueCheckFullFunction checkfull,
 
   g_return_val_if_fail (checkfull != NULL, NULL);
 
-  ret = g_object_new (GST_TYPE_DATA_QUEUE, NULL);
+  ret = g_object_newv (GST_TYPE_DATA_QUEUE, 0, NULL);
   ret->checkfull = checkfull;
   ret->checkdata = checkdata;
   ret->fullcallback = fullcallback;
index 04da352..2ce7bb0 100644 (file)
@@ -227,7 +227,7 @@ gst_controller_add_property (GstController * self, GObject * object,
     if ((prop = gst_controlled_property_new (object, name))) {
       /* if we don't have a controller object yet, now is the time to create one */
       if (!self) {
-        self = g_object_new (GST_TYPE_CONTROLLER, NULL);
+        self = g_object_newv (GST_TYPE_CONTROLLER, 0, NULL);
         self->object = g_object_ref (object);
         /* store the controller */
         g_object_set_qdata (object, priv_gst_controller_key, self);
index 919058a..5730fdf 100644 (file)
@@ -110,7 +110,7 @@ gst_interpolation_control_source_reset (GstInterpolationControlSource * self)
 GstInterpolationControlSource *
 gst_interpolation_control_source_new (void)
 {
-  return g_object_new (GST_TYPE_INTERPOLATION_CONTROL_SOURCE, NULL);
+  return g_object_newv (GST_TYPE_INTERPOLATION_CONTROL_SOURCE, 0, NULL);
 }
 
 /**
index 719a502..f791599 100644 (file)
@@ -566,7 +566,7 @@ gst_lfo_control_source_reset (GstLFOControlSource * self)
 GstLFOControlSource *
 gst_lfo_control_source_new (void)
 {
-  return g_object_new (GST_TYPE_LFO_CONTROL_SOURCE, NULL);
+  return g_object_newv (GST_TYPE_LFO_CONTROL_SOURCE, 0, NULL);
 }
 
 static gboolean