mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-02 09:16: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
|
* Returns: %TRUE if @type is a @is_a_type
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
g_type_is_a (GType type,
|
(g_type_is_a) (GType type,
|
||||||
GType iface_type)
|
GType iface_type)
|
||||||
{
|
{
|
||||||
TypeNode *node, *iface_node;
|
TypeNode *node, *iface_node;
|
||||||
gboolean is_a;
|
gboolean is_a;
|
||||||
|
@ -728,6 +728,10 @@ GType g_type_next_base (GType leaf_type
|
|||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
gboolean g_type_is_a (GType type,
|
gboolean g_type_is_a (GType type,
|
||||||
GType is_a_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
|
GLIB_AVAILABLE_IN_ALL
|
||||||
gpointer g_type_class_ref (GType type);
|
gpointer g_type_class_ref (GType type);
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
|
Loading…
Reference in New Issue
Block a user