mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
libs/base/typefindhelper: Remove useless typechecking in tight loop
The list against which we run the comparefunc will only contain GstPluginFeature, therefore remove the 6 expensive type checks we do for every single comparision.
This commit is contained in:
parent
7d86ad93a2
commit
bb0918279f
1 changed files with 11 additions and 8 deletions
|
@ -41,15 +41,15 @@
|
|||
#include "gsttypefindhelper.h"
|
||||
|
||||
static gint
|
||||
type_find_factory_rank_cmp (gconstpointer fac1, gconstpointer fac2)
|
||||
type_find_factory_rank_cmp (const GstPluginFeature * fac1,
|
||||
const GstPluginFeature * fac2)
|
||||
{
|
||||
if (GST_PLUGIN_FEATURE (fac1)->rank != GST_PLUGIN_FEATURE (fac2)->rank)
|
||||
return GST_PLUGIN_FEATURE (fac2)->rank - GST_PLUGIN_FEATURE (fac1)->rank;
|
||||
if (G_LIKELY (fac1->rank != fac2->rank))
|
||||
return fac2->rank - fac1->rank;
|
||||
|
||||
/* to make the order in which things happen more deterministic,
|
||||
* sort by name when the ranks are the same. */
|
||||
return strcmp (GST_PLUGIN_FEATURE_NAME (fac1),
|
||||
GST_PLUGIN_FEATURE_NAME (fac2));
|
||||
return strcmp (fac1->name, fac2->name);
|
||||
}
|
||||
|
||||
/* ********************** typefinding in pull mode ************************ */
|
||||
|
@ -281,7 +281,8 @@ gst_type_find_helper_get_range (GstObject * obj,
|
|||
|
||||
/* FIXME: we need to keep this list within the registry */
|
||||
type_list = gst_type_find_factory_get_list ();
|
||||
type_list = g_list_sort (type_list, type_find_factory_rank_cmp);
|
||||
type_list =
|
||||
g_list_sort (type_list, (GCompareFunc) type_find_factory_rank_cmp);
|
||||
|
||||
for (l = type_list; l; l = l->next) {
|
||||
helper.factory = GST_TYPE_FIND_FACTORY (l->data);
|
||||
|
@ -455,7 +456,8 @@ gst_type_find_helper_for_buffer (GstObject * obj, GstBuffer * buf,
|
|||
|
||||
/* FIXME: we need to keep this list within the registry */
|
||||
type_list = gst_type_find_factory_get_list ();
|
||||
type_list = g_list_sort (type_list, type_find_factory_rank_cmp);
|
||||
type_list =
|
||||
g_list_sort (type_list, (GCompareFunc) type_find_factory_rank_cmp);
|
||||
|
||||
for (l = type_list; l; l = l->next) {
|
||||
helper.factory = GST_TYPE_FIND_FACTORY (l->data);
|
||||
|
@ -504,7 +506,8 @@ gst_type_find_helper_for_extension (GstObject * obj, const gchar * extension)
|
|||
GST_LOG_OBJECT (obj, "finding caps for extension %s", extension);
|
||||
|
||||
type_list = gst_type_find_factory_get_list ();
|
||||
type_list = g_list_sort (type_list, type_find_factory_rank_cmp);
|
||||
type_list =
|
||||
g_list_sort (type_list, (GCompareFunc) type_find_factory_rank_cmp);
|
||||
|
||||
for (l = type_list; l; l = g_list_next (l)) {
|
||||
GstTypeFindFactory *factory;
|
||||
|
|
Loading…
Reference in a new issue