diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-01-15 02:35:21 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-01-16 17:03:51 -0500 |
commit | 789f6f3941bb1a3cc199ae5ebf14b94527c4e22d (patch) | |
tree | b5e0e03148318b52a84e8166435ce1dd0355f2d7 /gtk/gtkcssstaticstyle.c | |
parent | 2c231f4336b9824dffe41211eb776ff63a47240e (diff) | |
download | gtk+-789f6f3941bb1a3cc199ae5ebf14b94527c4e22d.tar.gz |
css: Avoid computing change too often
Most of the time when styles need to be recreated, the name and classes
of the css node haven't changed. In this case, the change value will not
change either, since we are computing change under the assumption that
name and classes are unchanged.
So don't recompute the change. This avoids the second match we do to
find the superset, cutting down the number of times we consult the
selector tree.
Diffstat (limited to 'gtk/gtkcssstaticstyle.c')
-rw-r--r-- | gtk/gtkcssstaticstyle.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c index d961731541..2ea6ddb1f8 100644 --- a/gtk/gtkcssstaticstyle.c +++ b/gtk/gtkcssstaticstyle.c @@ -165,7 +165,8 @@ gtk_css_static_style_get_default (void) settings = gtk_settings_get_default (); default_style = gtk_css_static_style_new_compute (GTK_STYLE_PROVIDER (settings), NULL, - NULL); + NULL, + TRUE); g_object_set_data_full (G_OBJECT (settings), I_("gtk-default-style"), default_style, clear_default_style); } @@ -176,11 +177,11 @@ gtk_css_static_style_get_default (void) GtkCssStyle * gtk_css_static_style_new_compute (GtkStyleProvider *provider, const GtkCssMatcher *matcher, - GtkCssStyle *parent) + GtkCssStyle *parent, + GtkCssChange change) { GtkCssStaticStyle *result; GtkCssLookup lookup; - GtkCssChange change = GTK_CSS_CHANGE_ANY_SELF | GTK_CSS_CHANGE_ANY_SIBLING | GTK_CSS_CHANGE_ANY_PARENT; _gtk_css_lookup_init (&lookup); @@ -188,7 +189,7 @@ gtk_css_static_style_new_compute (GtkStyleProvider *provider, gtk_style_provider_lookup (provider, matcher, &lookup, - &change); + change == 0 ? &change : NULL); result = g_object_new (GTK_TYPE_CSS_STATIC_STYLE, NULL); |