mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
gtype: small optimization
These warnings are never seen at runtime, so they are evidently very unlikely. Tell the compiler that.
This commit is contained in:
parent
6b5b1cd314
commit
c492f4aec2
@ -1858,13 +1858,13 @@ g_type_create_instance (GType type)
|
||||
guint i;
|
||||
|
||||
node = lookup_type_node_I (type);
|
||||
if (!node || !node->is_instantiatable)
|
||||
if (G_UNLIKELY (!node || !node->is_instantiatable))
|
||||
{
|
||||
g_error ("cannot create new instance of invalid (non-instantiatable) type '%s'",
|
||||
type_descriptive_name_I (type));
|
||||
}
|
||||
/* G_TYPE_IS_ABSTRACT() is an external call: _U */
|
||||
if (!node->mutatable_check_cache && G_TYPE_IS_ABSTRACT (type))
|
||||
if (G_UNLIKELY (!node->mutatable_check_cache && G_TYPE_IS_ABSTRACT (type)))
|
||||
{
|
||||
g_error ("cannot create instance of abstract (non-instantiatable) type '%s'",
|
||||
type_descriptive_name_I (type));
|
||||
@ -1893,7 +1893,7 @@ g_type_create_instance (GType type)
|
||||
ivar_size = node->data->instance.instance_size;
|
||||
|
||||
#ifdef ENABLE_VALGRIND
|
||||
if (private_size && RUNNING_ON_VALGRIND)
|
||||
if (G_UNLIKELY (private_size && RUNNING_ON_VALGRIND))
|
||||
{
|
||||
private_size += ALIGN_STRUCT (1);
|
||||
|
||||
@ -1963,14 +1963,14 @@ g_type_free_instance (GTypeInstance *instance)
|
||||
|
||||
class = instance->g_class;
|
||||
node = lookup_type_node_I (class->g_type);
|
||||
if (!node || !node->is_instantiatable || !node->data || node->data->class.class != (gpointer) class)
|
||||
if (G_UNLIKELY (!node || !node->is_instantiatable || !node->data || node->data->class.class != (gpointer) class))
|
||||
{
|
||||
g_warning ("cannot free instance of invalid (non-instantiatable) type '%s'",
|
||||
type_descriptive_name_I (class->g_type));
|
||||
return;
|
||||
}
|
||||
/* G_TYPE_IS_ABSTRACT() is an external call: _U */
|
||||
if (!node->mutatable_check_cache && G_TYPE_IS_ABSTRACT (NODE_TYPE (node)))
|
||||
if (G_UNLIKELY (!node->mutatable_check_cache && G_TYPE_IS_ABSTRACT (NODE_TYPE (node))))
|
||||
{
|
||||
g_warning ("cannot free instance of abstract (non-instantiatable) type '%s'",
|
||||
NODE_NAME (node));
|
||||
@ -1990,7 +1990,7 @@ g_type_free_instance (GTypeInstance *instance)
|
||||
/* See comment in g_type_create_instance() about what's going on here.
|
||||
* We're basically unwinding what we put into motion there.
|
||||
*/
|
||||
if (private_size && RUNNING_ON_VALGRIND)
|
||||
if (G_UNLIKELY (private_size && RUNNING_ON_VALGRIND))
|
||||
{
|
||||
private_size += ALIGN_STRUCT (1);
|
||||
allocated -= ALIGN_STRUCT (1);
|
||||
|
Loading…
Reference in New Issue
Block a user