[gtk+] cssprovider: Cache if rulesets have inheritable style properties
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] cssprovider: Cache if rulesets have inheritable style properties
- Date: Wed, 18 May 2011 20:33:11 +0000 (UTC)
commit 8111d99183bbe3f10ba4260d319925ae1fc6b96e
Author: Benjamin Otte <otte redhat com>
Date: Wed May 18 05:47:18 2011 +0200
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.
gtk/gtkcssprovider.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 8dcb09a..8659247 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -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))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]