[glib/gobject-speedups: 11/13] gtype: small optimization
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/gobject-speedups: 11/13] gtype: small optimization
- Date: Mon, 16 May 2022 12:09:26 +0000 (UTC)
commit 29606c14343636b8dcb54fb0bd91d3af67b0e64b
Author: Matthias Clasen <mclasen redhat com>
Date: Sun May 15 22:12:58 2022 -0400
gtype: small optimization
gobject/gtype.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/gobject/gtype.c b/gobject/gtype.c
index cf213b760a..c08f11345d 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]