mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
gst/gststructure.c: No need to memset, we can clear the value ourselves.
Original commit message from CVS: * gst/gststructure.c: (gst_structure_id_empty_new_with_size): No need to memset, we can clear the value ourselves. * gst/gstvalue.c: (gst_type_is_fixed), (gst_value_get_compare_func): Some optimisations from a few callgrind sessions: When checking if a type is fixed, check for trivial fundamental types first before checking types for which we need to get the type followed by the heavy duty type checks, this reduces the amount of g_type_fundamental() calls a lot. When getting the compare function, first check for our registered types. If that fails, do the heavy duty g_type_is_a() checks, reduces the amount of g_type_is_a() considerably.
This commit is contained in:
parent
773c1e4c1d
commit
209c57085c
3 changed files with 42 additions and 13 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
||||||
|
2008-11-05 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
|
* gst/gststructure.c: (gst_structure_id_empty_new_with_size):
|
||||||
|
No need to memset, we can clear the value ourselves.
|
||||||
|
|
||||||
|
* gst/gstvalue.c: (gst_type_is_fixed),
|
||||||
|
(gst_value_get_compare_func):
|
||||||
|
Some optimisations from a few callgrind sessions:
|
||||||
|
When checking if a type is fixed, check for trivial fundamental types
|
||||||
|
first before checking types for which we need to get the type followed
|
||||||
|
by the heavy duty type checks, this reduces the amount of
|
||||||
|
g_type_fundamental() calls a lot.
|
||||||
|
When getting the compare function, first check for our registered types.
|
||||||
|
If that fails, do the heavy duty g_type_is_a() checks, reduces the
|
||||||
|
amount of g_type_is_a() considerably.
|
||||||
|
|
||||||
2008-11-05 Wim Taymans <wim.taymans@collabora.co.uk>
|
2008-11-05 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
* docs/design/part-TODO.txt:
|
* docs/design/part-TODO.txt:
|
||||||
|
|
|
@ -113,9 +113,10 @@ gst_structure_id_empty_new_with_size (GQuark quark, guint prealloc)
|
||||||
{
|
{
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
|
||||||
structure = g_slice_new0 (GstStructure);
|
structure = g_slice_new (GstStructure);
|
||||||
structure->type = gst_structure_get_type ();
|
structure->type = gst_structure_get_type ();
|
||||||
structure->name = quark;
|
structure->name = quark;
|
||||||
|
structure->parent_refcount = NULL;
|
||||||
structure->fields =
|
structure->fields =
|
||||||
g_array_sized_new (FALSE, TRUE, sizeof (GstStructureField), prealloc);
|
g_array_sized_new (FALSE, TRUE, sizeof (GstStructureField), prealloc);
|
||||||
|
|
||||||
|
|
|
@ -148,20 +148,25 @@ gst_value_transform_any_list_string (const GValue * src_value,
|
||||||
* there. Do not export, since it doesn't work for types where the content
|
* there. Do not export, since it doesn't work for types where the content
|
||||||
* decides the fixedness (e.g. GST_TYPE_ARRAY).
|
* decides the fixedness (e.g. GST_TYPE_ARRAY).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_type_is_fixed (GType type)
|
gst_type_is_fixed (GType type)
|
||||||
{
|
{
|
||||||
if (type == GST_TYPE_INT_RANGE || type == GST_TYPE_DOUBLE_RANGE ||
|
/* the basic int, string, double types */
|
||||||
type == GST_TYPE_LIST) {
|
if (type <= G_TYPE_MAKE_FUNDAMENTAL (G_TYPE_RESERVED_GLIB_LAST)) {
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (G_TYPE_FUNDAMENTAL (type) <=
|
|
||||||
G_TYPE_MAKE_FUNDAMENTAL (G_TYPE_RESERVED_GLIB_LAST)) {
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (type == GST_TYPE_BUFFER || type == GST_TYPE_FOURCC
|
/* our fundamental types that are certainly not fixed */
|
||||||
|| type == GST_TYPE_ARRAY || type == GST_TYPE_FRACTION) {
|
if (type == GST_TYPE_INT_RANGE || type == GST_TYPE_DOUBLE_RANGE ||
|
||||||
|
type == GST_TYPE_LIST || type == GST_TYPE_FRACTION_RANGE) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
/* other (boxed) types that are fixed */
|
||||||
|
if (type == GST_TYPE_BUFFER) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
/* heavy checks */
|
||||||
|
if (G_TYPE_IS_FUNDAMENTAL (type) || G_TYPE_FUNDAMENTAL (type) <=
|
||||||
|
G_TYPE_MAKE_FUNDAMENTAL (G_TYPE_RESERVED_GLIB_LAST)) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2795,15 +2800,22 @@ gst_value_get_compare_func (const GValue * value1)
|
||||||
GstValueTable *table, *best = NULL;
|
GstValueTable *table, *best = NULL;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
|
/* this is a fast check */
|
||||||
for (i = 0; i < gst_value_table->len; i++) {
|
for (i = 0; i < gst_value_table->len; i++) {
|
||||||
table = &g_array_index (gst_value_table, GstValueTable, i);
|
table = &g_array_index (gst_value_table, GstValueTable, i);
|
||||||
if (table->type == G_VALUE_TYPE (value1) && table->compare != NULL) {
|
if (table->type == G_VALUE_TYPE (value1) && table->compare != NULL) {
|
||||||
best = table;
|
best = table;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (g_type_is_a (G_VALUE_TYPE (value1), table->type)) {
|
}
|
||||||
if (!best || g_type_is_a (table->type, best->type))
|
/* slower checks */
|
||||||
best = table;
|
if (!best) {
|
||||||
|
for (i = 0; i < gst_value_table->len; i++) {
|
||||||
|
table = &g_array_index (gst_value_table, GstValueTable, i);
|
||||||
|
if (g_type_is_a (G_VALUE_TYPE (value1), table->type)) {
|
||||||
|
if (!best || g_type_is_a (table->type, best->type))
|
||||||
|
best = table;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (best) {
|
if (best) {
|
||||||
|
|
Loading…
Reference in a new issue