Commit 27284628 authored by Edward Hervey's avatar Edward Hervey 🤘

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)
parent 118509af
......@@ -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;
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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));
......
......@@ -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));
}
/**
......
......@@ -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);
}
/**
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
}
/**
......
......@@ -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
......
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