From 27284628e4123e85ae9719f0a2376a221940ae55 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 28 Oct 2009 09:26:32 +0100 Subject: [PATCH] optimisation : Use g_object_newv where possible. 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) --- gst/gstbus.c | 2 +- gst/gstelementfactory.c | 5 +++-- gst/gstindex.c | 2 +- gst/gstindexfactory.c | 4 ++-- gst/gstobject.c | 2 +- gst/gstplugin.c | 6 +++--- gst/gstpluginloader.c | 2 +- gst/gstregistry.c | 2 +- gst/gstregistrychunks.c | 4 ++-- gst/gsttask.c | 2 +- gst/gsttaskpool.c | 2 +- gst/gsttypefind.c | 2 +- gst/gstxml.c | 2 +- libs/gst/base/gstadapter.c | 2 +- libs/gst/base/gstcollectpads.c | 2 +- libs/gst/base/gstdataqueue.c | 2 +- libs/gst/controller/gstcontroller.c | 2 +- libs/gst/controller/gstinterpolationcontrolsource.c | 2 +- libs/gst/controller/gstlfocontrolsource.c | 2 +- 19 files changed, 25 insertions(+), 24 deletions(-) diff --git a/gst/gstbus.c b/gst/gstbus.c index 6088b8196a..2df4cb94a0 100644 --- a/gst/gstbus.c +++ b/gst/gstbus.c @@ -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; diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 8c47a5a35d..0cdb5ffd21 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -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; diff --git a/gst/gstindex.c b/gst/gstindex.c index 0b3391f5c7..0a70c3b3e2 100644 --- a/gst/gstindex.c +++ b/gst/gstindex.c @@ -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; } diff --git a/gst/gstindexfactory.c b/gst/gstindexfactory.c index 403144d7c4..97083d7741 100644 --- a/gst/gstindexfactory.c +++ b/gst/gstindexfactory.c @@ -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); diff --git a/gst/gstobject.c b/gst/gstobject.c index 000b347073..52b3fb1c0f 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -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 diff --git a/gst/gstplugin.c b/gst/gstplugin.c index 0d29ce35fd..609a7890a9 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -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); diff --git a/gst/gstpluginloader.c b/gst/gstpluginloader.c index f69c1e3537..36b796a21d 100644 --- a/gst/gstpluginloader.c +++ b/gst/gstpluginloader.c @@ -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; diff --git a/gst/gstregistry.c b/gst/gstregistry.c index 9e4efd245d..56f4744a34 100644 --- a/gst/gstregistry.c +++ b/gst/gstregistry.c @@ -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; diff --git a/gst/gstregistrychunks.c b/gst/gstregistrychunks.c index d81542b563..e1e7dece21 100644 --- a/gst/gstregistrychunks.c +++ b/gst/gstregistrychunks.c @@ -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; diff --git a/gst/gsttask.c b/gst/gsttask.c index b376b0b4af..e55fa58b6e 100644 --- a/gst/gsttask.c +++ b/gst/gsttask.c @@ -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; diff --git a/gst/gsttaskpool.c b/gst/gsttaskpool.c index 9ca2ffad43..e065fcad32 100644 --- a/gst/gsttaskpool.c +++ b/gst/gsttaskpool.c @@ -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; } diff --git a/gst/gsttypefind.c b/gst/gsttypefind.c index 756e8824af..8f43b2604e 100644 --- a/gst/gsttypefind.c +++ b/gst/gsttypefind.c @@ -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)); diff --git a/gst/gstxml.c b/gst/gstxml.c index 1d7185caa7..fd3daf1121 100644 --- a/gst/gstxml.c +++ b/gst/gstxml.c @@ -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)); } /** diff --git a/libs/gst/base/gstadapter.c b/libs/gst/base/gstadapter.c index d326556540..ae864d22d1 100644 --- a/libs/gst/base/gstadapter.c +++ b/libs/gst/base/gstadapter.c @@ -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); } /** diff --git a/libs/gst/base/gstcollectpads.c b/libs/gst/base/gstcollectpads.c index 8f75e7e317..77a1ba3b0e 100644 --- a/libs/gst/base/gstcollectpads.c +++ b/libs/gst/base/gstcollectpads.c @@ -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; } diff --git a/libs/gst/base/gstdataqueue.c b/libs/gst/base/gstdataqueue.c index 5dbd420c43..b408b425aa 100644 --- a/libs/gst/base/gstdataqueue.c +++ b/libs/gst/base/gstdataqueue.c @@ -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; diff --git a/libs/gst/controller/gstcontroller.c b/libs/gst/controller/gstcontroller.c index 04da3524cc..2ce7bb04f2 100644 --- a/libs/gst/controller/gstcontroller.c +++ b/libs/gst/controller/gstcontroller.c @@ -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); diff --git a/libs/gst/controller/gstinterpolationcontrolsource.c b/libs/gst/controller/gstinterpolationcontrolsource.c index 919058ae28..5730fdff27 100644 --- a/libs/gst/controller/gstinterpolationcontrolsource.c +++ b/libs/gst/controller/gstinterpolationcontrolsource.c @@ -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); } /** diff --git a/libs/gst/controller/gstlfocontrolsource.c b/libs/gst/controller/gstlfocontrolsource.c index 719a50227c..f791599066 100644 --- a/libs/gst/controller/gstlfocontrolsource.c +++ b/libs/gst/controller/gstlfocontrolsource.c @@ -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