gtype: Add check for fundamental instance type

When checking whether an instance is of a given fundamental type (such
as G_TYPE_OBJECT), we can avoid over 60%+ of the cost of checking types.

https://bugzilla.gnome.org/show_bug.cgi?id=730984
This commit is contained in:
Edward Hervey
2014-05-28 10:57:28 +02:00
committed by Ryan Lortie
parent 03a48e1ade
commit 6072e3650f
3 changed files with 27 additions and 0 deletions

View File

@@ -3974,6 +3974,15 @@ g_type_check_instance_is_a (GTypeInstance *type_instance,
return check;
}
gboolean
g_type_check_instance_is_fundamentally_a (GTypeInstance *type_instance,
GType fundamental_type)
{
if (!type_instance || !type_instance->g_class)
return FALSE;
return NODE_FUNDAMENTAL_TYPE(lookup_type_node_I (type_instance->g_class->g_type)) == fundamental_type;
}
gboolean
g_type_check_class_is_a (GTypeClass *type_class,
GType is_a_type)