gst/: Use _CAST macros to avoid unneeded type checking.

Original commit message from CVS:
* gst/gst.c: (gst_debug_help):
* gst/gstplugin.c: (gst_plugin_finalize), (gst_plugin_list_free):
* gst/gstpluginfeature.c: (gst_plugin_feature_finalize),
(gst_plugin_feature_list_free):
* gst/gstregistry.c: (gst_registry_add_plugin),
(gst_registry_add_feature), (gst_registry_plugin_filter),
(gst_registry_feature_filter), (gst_registry_find_plugin),
(gst_registry_find_feature), (gst_registry_get_plugin_list),
(gst_registry_lookup_feature_locked), (gst_registry_lookup_locked):
* gst/gstregistryxml.c: (load_feature),
(gst_registry_xml_read_cache), (gst_registry_xml_write_cache):
* gst/gstminiobject.c: (gst_mini_object_unref),
(gst_mini_object_replace), (gst_value_mini_object_free),
(gst_value_mini_object_copy):
Use _CAST macros to avoid unneeded type checking.
Added some more G_UNLIKELY.
This commit is contained in:
Wim Taymans 2006-06-12 09:17:44 +00:00
parent bc1bdfabab
commit 259eecdabc
7 changed files with 51 additions and 23 deletions

View file

@ -1,3 +1,22 @@
2006-06-12 Wim Taymans <wim@fluendo.com>
* gst/gst.c: (gst_debug_help):
* gst/gstplugin.c: (gst_plugin_finalize), (gst_plugin_list_free):
* gst/gstpluginfeature.c: (gst_plugin_feature_finalize),
(gst_plugin_feature_list_free):
* gst/gstregistry.c: (gst_registry_add_plugin),
(gst_registry_add_feature), (gst_registry_plugin_filter),
(gst_registry_feature_filter), (gst_registry_find_plugin),
(gst_registry_find_feature), (gst_registry_get_plugin_list),
(gst_registry_lookup_feature_locked), (gst_registry_lookup_locked):
* gst/gstregistryxml.c: (load_feature),
(gst_registry_xml_read_cache), (gst_registry_xml_write_cache):
* gst/gstminiobject.c: (gst_mini_object_unref),
(gst_mini_object_replace), (gst_value_mini_object_free),
(gst_value_mini_object_copy):
Use _CAST macros to avoid unneeded type checking.
Added some more G_UNLIKELY.
2006-06-12 Wim Taymans <wim@fluendo.com> 2006-06-12 Wim Taymans <wim@fluendo.com>
* gst/gstbuffer.h: * gst/gstbuffer.h:

View file

@ -772,7 +772,7 @@ gst_debug_help (void)
/* FIXME this is gross. why don't debug have categories PluginFeatures? */ /* FIXME this is gross. why don't debug have categories PluginFeatures? */
for (g = list2; g; g = g_list_next (g)) { for (g = list2; g; g = g_list_next (g)) {
GstPlugin *plugin = GST_PLUGIN (g->data); GstPlugin *plugin = GST_PLUGIN_CAST (g->data);
gst_plugin_load (plugin); gst_plugin_load (plugin);
} }

View file

@ -300,7 +300,7 @@ gst_mini_object_unref (GstMiniObject * mini_object)
GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) - 1); GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) - 1);
#endif #endif
if (g_atomic_int_dec_and_test (&mini_object->refcount)) { if (G_UNLIKELY (g_atomic_int_dec_and_test (&mini_object->refcount))) {
gst_mini_object_free (mini_object); gst_mini_object_free (mini_object);
} }
} }
@ -319,6 +319,12 @@ gst_mini_object_replace (GstMiniObject ** olddata, GstMiniObject * newdata)
{ {
GstMiniObject *olddata_val; GstMiniObject *olddata_val;
#ifdef DEBUG_REFCOUNT
GST_CAT_LOG (GST_CAT_REFCOUNTING, "replace %p (%d) with %p (%d)",
*olddata, *olddata ? (*olddata)->refcount : 0,
newdata, newdata ? newdata->refcount : 0);
#endif
if (newdata) if (newdata)
gst_mini_object_ref (newdata); gst_mini_object_ref (newdata);
@ -341,7 +347,7 @@ static void
gst_value_mini_object_free (GValue * value) gst_value_mini_object_free (GValue * value)
{ {
if (value->data[0].v_pointer) { if (value->data[0].v_pointer) {
gst_mini_object_unref (GST_MINI_OBJECT (value->data[0].v_pointer)); gst_mini_object_unref (GST_MINI_OBJECT_CAST (value->data[0].v_pointer));
} }
} }
@ -350,7 +356,8 @@ gst_value_mini_object_copy (const GValue * src_value, GValue * dest_value)
{ {
if (src_value->data[0].v_pointer) { if (src_value->data[0].v_pointer) {
dest_value->data[0].v_pointer = dest_value->data[0].v_pointer =
gst_mini_object_ref (GST_MINI_OBJECT (src_value->data[0].v_pointer)); gst_mini_object_ref (GST_MINI_OBJECT_CAST (src_value->data[0].
v_pointer));
} else { } else {
dest_value->data[0].v_pointer = NULL; dest_value->data[0].v_pointer = NULL;
} }

View file

@ -124,7 +124,7 @@ gst_plugin_init (GstPlugin * plugin)
static void static void
gst_plugin_finalize (GObject * object) gst_plugin_finalize (GObject * object)
{ {
GstPlugin *plugin = GST_PLUGIN (object); GstPlugin *plugin = GST_PLUGIN_CAST (object);
GstRegistry *registry = gst_registry_get_default (); GstRegistry *registry = gst_registry_get_default ();
GList *g; GList *g;
@ -935,7 +935,7 @@ gst_plugin_list_free (GList * list)
GList *g; GList *g;
for (g = list; g; g = g->next) { for (g = list; g; g = g->next) {
gst_object_unref (GST_PLUGIN (g->data)); gst_object_unref (GST_PLUGIN_CAST (g->data));
} }
g_list_free (list); g_list_free (list);
} }

View file

@ -66,7 +66,7 @@ gst_plugin_feature_init (GstPluginFeature * feature)
static void static void
gst_plugin_feature_finalize (GObject * object) gst_plugin_feature_finalize (GObject * object)
{ {
GstPluginFeature *feature = GST_PLUGIN_FEATURE (object); GstPluginFeature *feature = GST_PLUGIN_FEATURE_CAST (object);
GST_DEBUG ("finalizing feature %p: '%s'", feature, GST_DEBUG ("finalizing feature %p: '%s'", feature,
GST_PLUGIN_FEATURE_NAME (feature)); GST_PLUGIN_FEATURE_NAME (feature));
@ -252,7 +252,7 @@ gst_plugin_feature_list_free (GList * list)
GList *g; GList *g;
for (g = list; g; g = g->next) { for (g = list; g; g = g->next) {
GstPluginFeature *feature = GST_PLUGIN_FEATURE (g->data); GstPluginFeature *feature = GST_PLUGIN_FEATURE_CAST (g->data);
gst_object_unref (feature); gst_object_unref (feature);
} }

View file

@ -314,7 +314,7 @@ gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin)
GST_OBJECT_LOCK (registry); GST_OBJECT_LOCK (registry);
existing_plugin = gst_registry_lookup_locked (registry, plugin->filename); existing_plugin = gst_registry_lookup_locked (registry, plugin->filename);
if (existing_plugin) { if (G_UNLIKELY (existing_plugin)) {
GST_DEBUG_OBJECT (registry, GST_DEBUG_OBJECT (registry,
"Replacing existing plugin %p with new plugin %p for filename \"%s\"", "Replacing existing plugin %p with new plugin %p for filename \"%s\"",
existing_plugin, plugin, GST_STR_NULL (plugin->filename)); existing_plugin, plugin, GST_STR_NULL (plugin->filename));
@ -385,7 +385,7 @@ gst_registry_add_feature (GstRegistry * registry, GstPluginFeature * feature)
GST_OBJECT_LOCK (registry); GST_OBJECT_LOCK (registry);
existing_feature = gst_registry_lookup_feature_locked (registry, existing_feature = gst_registry_lookup_feature_locked (registry,
feature->name); feature->name);
if (existing_feature) { if (G_UNLIKELY (existing_feature)) {
GST_DEBUG_OBJECT (registry, "Replacing existing feature %p (%s)", GST_DEBUG_OBJECT (registry, "Replacing existing feature %p (%s)",
existing_feature, feature->name); existing_feature, feature->name);
registry->features = g_list_remove (registry->features, existing_feature); registry->features = g_list_remove (registry->features, existing_feature);
@ -461,7 +461,7 @@ gst_registry_plugin_filter (GstRegistry * registry,
list = gst_filter_run (registry->plugins, (GstFilterFunc) filter, first, list = gst_filter_run (registry->plugins, (GstFilterFunc) filter, first,
user_data); user_data);
for (g = list; g; g = g->next) { for (g = list; g; g = g->next) {
gst_object_ref (GST_PLUGIN (g->data)); gst_object_ref (GST_PLUGIN_CAST (g->data));
} }
GST_OBJECT_UNLOCK (registry); GST_OBJECT_UNLOCK (registry);
@ -497,7 +497,7 @@ gst_registry_feature_filter (GstRegistry * registry,
list = gst_filter_run (registry->features, (GstFilterFunc) filter, first, list = gst_filter_run (registry->features, (GstFilterFunc) filter, first,
user_data); user_data);
for (g = list; g; g = g->next) { for (g = list; g; g = g->next) {
gst_object_ref (GST_PLUGIN_FEATURE (g->data)); gst_object_ref (GST_PLUGIN_FEATURE_CAST (g->data));
} }
GST_OBJECT_UNLOCK (registry); GST_OBJECT_UNLOCK (registry);
@ -529,7 +529,7 @@ gst_registry_find_plugin (GstRegistry * registry, const gchar * name)
walk = gst_registry_plugin_filter (registry, walk = gst_registry_plugin_filter (registry,
(GstPluginFilter) gst_plugin_name_filter, TRUE, (gpointer) name); (GstPluginFilter) gst_plugin_name_filter, TRUE, (gpointer) name);
if (walk) { if (walk) {
result = GST_PLUGIN (walk->data); result = GST_PLUGIN_CAST (walk->data);
gst_object_ref (result); gst_object_ref (result);
gst_plugin_list_free (walk); gst_plugin_list_free (walk);
@ -571,7 +571,7 @@ gst_registry_find_feature (GstRegistry * registry, const gchar * name,
TRUE, &data); TRUE, &data);
if (walk) { if (walk) {
feature = GST_PLUGIN_FEATURE (walk->data); feature = GST_PLUGIN_FEATURE_CAST (walk->data);
gst_object_ref (feature); gst_object_ref (feature);
gst_plugin_feature_list_free (walk); gst_plugin_feature_list_free (walk);
@ -630,7 +630,7 @@ gst_registry_get_plugin_list (GstRegistry * registry)
GST_OBJECT_LOCK (registry); GST_OBJECT_LOCK (registry);
list = g_list_copy (registry->plugins); list = g_list_copy (registry->plugins);
for (g = list; g; g = g->next) { for (g = list; g; g = g->next) {
gst_object_ref (GST_PLUGIN (g->data)); gst_object_ref (GST_PLUGIN_CAST (g->data));
} }
GST_OBJECT_UNLOCK (registry); GST_OBJECT_UNLOCK (registry);
@ -643,11 +643,11 @@ gst_registry_lookup_feature_locked (GstRegistry * registry, const char *name)
GList *g; GList *g;
GstPluginFeature *feature; GstPluginFeature *feature;
if (name == NULL) if (G_UNLIKELY (name == NULL))
return NULL; return NULL;
for (g = registry->features; g; g = g_list_next (g)) { for (g = registry->features; g; g = g_list_next (g)) {
feature = GST_PLUGIN_FEATURE (g->data); feature = GST_PLUGIN_FEATURE_CAST (g->data);
if (feature->name && strcmp (name, feature->name) == 0) { if (feature->name && strcmp (name, feature->name) == 0) {
return feature; return feature;
} }
@ -692,12 +692,12 @@ gst_registry_lookup_locked (GstRegistry * registry, const char *filename)
GstPlugin *plugin; GstPlugin *plugin;
gchar *basename; gchar *basename;
if (filename == NULL) if (G_UNLIKELY (filename == NULL))
return NULL; return NULL;
basename = g_path_get_basename (filename); basename = g_path_get_basename (filename);
for (g = registry->plugins; g; g = g_list_next (g)) { for (g = registry->plugins; g; g = g_list_next (g)) {
plugin = GST_PLUGIN (g->data); plugin = GST_PLUGIN_CAST (g->data);
if (plugin->basename && strcmp (basename, plugin->basename) == 0) { if (plugin->basename && strcmp (basename, plugin->basename) == 0) {
g_free (basename); g_free (basename);
return plugin; return plugin;

View file

@ -284,10 +284,11 @@ load_feature (xmlTextReaderPtr reader)
if (g_str_equal (tag, "name")) if (g_str_equal (tag, "name"))
read_string (reader, &feature->name, FALSE); read_string (reader, &feature->name, FALSE);
if (g_str_equal (tag, "rank")) else if (g_str_equal (tag, "rank"))
read_uint (reader, &feature->rank); read_uint (reader, &feature->rank);
if (GST_IS_ELEMENT_FACTORY (feature)) { if (GST_IS_ELEMENT_FACTORY (feature)) {
GstElementFactory *factory = GST_ELEMENT_FACTORY (feature); GstElementFactory *factory = GST_ELEMENT_FACTORY_CAST (feature);
if (g_str_equal (tag, "longname")) { if (g_str_equal (tag, "longname")) {
int ret; int ret;
@ -544,7 +545,8 @@ gst_registry_xml_read_cache (GstRegistry * registry, const char *location)
GST_DEBUG ("adding plugin %s", plugin->desc.name); GST_DEBUG ("adding plugin %s", plugin->desc.name);
gst_registry_add_plugin (registry, plugin); gst_registry_add_plugin (registry, plugin);
for (g = feature_list; g; g = g_list_next (g)) { for (g = feature_list; g; g = g_list_next (g)) {
gst_registry_add_feature (registry, GST_PLUGIN_FEATURE (g->data)); gst_registry_add_feature (registry,
GST_PLUGIN_FEATURE_CAST (g->data));
} }
g_list_free (feature_list); g_list_free (feature_list);
} }
@ -853,7 +855,7 @@ gst_registry_xml_write_cache (GstRegistry * registry, const char *location)
for (walk = g_list_last (registry->plugins); walk; for (walk = g_list_last (registry->plugins); walk;
walk = g_list_previous (walk)) { walk = g_list_previous (walk)) {
GstPlugin *plugin = GST_PLUGIN (walk->data); GstPlugin *plugin = GST_PLUGIN_CAST (walk->data);
if (!plugin->filename) if (!plugin->filename)
continue; continue;