GValue checks for non-derivable types could be faster
Submitted by Allison (desrt)
Link to original bug (#670075)
Description
For functions like g_value_set_int() we have:
g_return_if_fail (G_VALUE_HOLDS_INT (value));
which looks like it should be fast enough, until you realise:
#define G_VALUE_HOLDS_INT(value)
(G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT))
ie: we are using the full derivation-capable typechecking machinery for non-derivable types.
There is a check in the macro to handle equality as a special case but it's nested inside of an if/elseif/else structure that is probably difficult for the compiler to reason about.
We could have more efficient implementations of G_VALUE_HOLDS_INT() and friends that just do a simple equality compare.