widget: Speed up verify_invariants()

Hide the expensive GTK_IS_ROOT() checks behind the cheaper realized,
mapped, etc. checks. This way we only check for the widget being a root
if the invariant does not hold.

This gets pop_verify_invariants() from 16% to 6% when running the
scrolling benchmark in the widget-factory.
This commit is contained in:
Timm Bäder 2020-02-06 08:17:51 +01:00 committed by Matthias Clasen
parent b561eb8299
commit e152d25ac0

View File

@ -6332,12 +6332,9 @@ gtk_widget_verify_invariants (GtkWidget *widget)
g_warning ("%s %p is mapped but not visible",
gtk_widget_get_name (widget), widget);
if (!GTK_IS_ROOT (widget))
{
if (!priv->child_visible)
g_warning ("%s %p is mapped but not child_visible",
gtk_widget_get_name (widget), widget);
}
if (!priv->child_visible && !GTK_IS_ROOT (widget))
g_warning ("%s %p is mapped but not child_visible",
gtk_widget_get_name (widget), widget);
}
else
{
@ -6380,14 +6377,12 @@ gtk_widget_verify_invariants (GtkWidget *widget)
G_OBJECT_TYPE_NAME (widget), widget);
#endif
}
else if (!GTK_IS_ROOT (widget))
else if (priv->realized && !GTK_IS_ROOT (widget))
{
/* No parent or parent not realized on non-toplevel implies... */
if (priv->realized)
g_warning ("%s %p is not realized but child %s %p is realized",
parent ? gtk_widget_get_name (parent) : "no parent", parent,
gtk_widget_get_name (widget), widget);
g_warning ("%s %p is not realized but child %s %p is realized",
parent ? gtk_widget_get_name (parent) : "no parent", parent,
gtk_widget_get_name (widget), widget);
}
if (parent &&
@ -6402,17 +6397,15 @@ gtk_widget_verify_invariants (GtkWidget *widget)
gtk_widget_get_name (parent), parent,
gtk_widget_get_name (widget), widget);
}
else if (!GTK_IS_ROOT (widget))
else if (priv->mapped && !GTK_IS_ROOT (widget))
{
/* No parent or parent not mapped on non-toplevel implies... */
if (priv->mapped)
g_warning ("%s %p is mapped but visible=%d child_visible=%d parent %s %p mapped=%d",
gtk_widget_get_name (widget), widget,
priv->visible,
priv->child_visible,
parent ? gtk_widget_get_name (parent) : "no parent", parent,
parent ? parent->priv->mapped : FALSE);
g_warning ("%s %p is mapped but visible=%d child_visible=%d parent %s %p mapped=%d",
gtk_widget_get_name (widget), widget,
priv->visible,
priv->child_visible,
parent ? gtk_widget_get_name (parent) : "no parent", parent,
parent ? parent->priv->mapped : FALSE);
}
}