cssprovider: Cache if rulesets have inheritable style properties

This provides a huge speedup as we only need to preprocess style
properties when they are indeed inherited. This roughly doubles the
performance of the CSS matcher and brings the time taken by
gtk_css_provider_get_style() from 19% to 7% in my favorite benchmark.
This commit is contained in:
Benjamin Otte 2011-05-18 05:47:18 +02:00
parent 82b340f6f0
commit 8111d99183

View File

@ -745,6 +745,8 @@ struct GtkCssRuleset
GtkCssSelector *selector;
GHashTable *widget_style;
GHashTable *style;
guint has_inherit :1;
};
struct _GtkCssScanner
@ -970,6 +972,7 @@ gtk_css_ruleset_add (GtkCssRuleset *ruleset,
NULL,
(GDestroyNotify) property_value_free);
ruleset->has_inherit |= gtk_style_param_get_inherit (pspec);
g_hash_table_insert (ruleset->style, pspec, value);
}
@ -1158,7 +1161,7 @@ gtk_css_provider_get_style (GtkStyleProvider *provider,
if (ruleset->style == NULL)
continue;
if (l < length && _gtk_css_selector_get_state_flags (ruleset->selector))
if (l < length && (!ruleset->has_inherit || _gtk_css_selector_get_state_flags (ruleset->selector)))
continue;
if (!gtk_css_ruleset_matches (ruleset, path, l))