mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-23 04:36:17 +01:00
gtype: Speed up g_type_is_a
As noticed by Christian Hergert: We can reduce some overhead by checking for exact type equality first. According to Christian, around 3% of g_type_is_a calls are exact equalities.
This commit is contained in:
parent
c492f4aec2
commit
22f51b87a2
@ -3577,8 +3577,8 @@ type_node_conforms_to_U (TypeNode *node,
|
||||
* Returns: %TRUE if @type is a @is_a_type
|
||||
*/
|
||||
gboolean
|
||||
g_type_is_a (GType type,
|
||||
GType iface_type)
|
||||
(g_type_is_a) (GType type,
|
||||
GType iface_type)
|
||||
{
|
||||
TypeNode *node, *iface_node;
|
||||
gboolean is_a;
|
||||
|
@ -728,6 +728,10 @@ GType g_type_next_base (GType leaf_type
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
gboolean g_type_is_a (GType type,
|
||||
GType is_a_type);
|
||||
|
||||
/* Hoist exact GType comparisons into the caller */
|
||||
#define g_type_is_a(a,b) ((a) == (b) || (g_type_is_a) ((a), (b)))
|
||||
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
gpointer g_type_class_ref (GType type);
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
|
Loading…
Reference in New Issue
Block a user