GNOME Bugzilla – Bug 731892
gstvalue: Avoid expensive g_type_check_value_holds calls when dealing with fundamental GType
Last modified: 2014-06-20 10:27:29 UTC
+++ This bug was initially created as a clone of Bug #731756 +++ The follow up of the upstream bug is that when dealing with fundamental type gvalue (which is.... er.... all our basic types), we can just avoid calling G_VALUE_HOLDS altogether and instead just do a simple (v && (G_VALUE_TYPE(v) == type))
Created attachment 278731 [details] [review] gstvalue: Check GValue type directly for fundamentals When wanting to check whether a GValue is of a certain fundamental type, we can just check directly the GValue type instead of doing a more expensive G_VALUE_HOLDS (which calls g_type_check_value_holds()) Benchmark: * valgrind callgrind (instruction calls): gst_value_compare: 48% to 58% of the calls (70 to 100% speedup) gst_value_subtract: 62% to 79% of the calls (27 to 60% speedup) gst_value_intersect: 51% to 60% of the calls (66 to 94% speedup)
Review of attachment 278731 [details] [review]: ::: gst/gstvalue.c @@ +44,3 @@ #include "gstutils.h" +#define GST_VALUE_HOLDS_FUNDAMENTAL(v,t) ((v) && ((v)->g_type == t)) GST_VALUE_HOLDS_EXACTLY() instead maybe? Fundamental values can have subtypes Also you might want to use that for G_TYPE_INT, _STRING, other basic types too. All over the file. In theory they can have subtypes but we don't support that currently either
I think this is obsolete now: commit 6880844d8a9a0d4cd1703e5d197ee3ae2cc20819 Author: Tim-Philipp Müller <tim@centricular.com> Date: Tue Jun 17 22:45:57 2014 +0100 value: simplify GST_VALUE_HOLDS for our boxed and fundamental types Boxed types can't be derived from, and we don't support deriving from our special fundamental types (the code checks for GType equality in most places. commit bc75a166f01d7e75b0990f17b9f85fad9ad8585f Author: Tim-Philipp Müller <tim@centricular.com> Date: Thu Jun 19 08:09:55 2014 +0100 gstvalue: optimise checks for lists Our fundamental types are non-derivable, so we can just check for equality. Also avoid doing the same check multiple times in a couple of places. (sorry for the duplicate work, but I had been working on that already, just hadn't pushed it yet because of the unit tests needing fixing for the compiler warning)