mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-23 01:18:53 +02:00
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:
committed by
Ryan Lortie
parent
03a48e1ade
commit
6072e3650f
@@ -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)
|
||||
|
Reference in New Issue
Block a user