[gtk+] cssprovider: Speed up gtk_widget_style_get() property lookups
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] cssprovider: Speed up gtk_widget_style_get() property lookups
- Date: Wed, 18 May 2011 20:31:50 +0000 (UTC)
commit 8605a2a10a51d5f46e7169358199f2eeb440a0e2
Author: Benjamin Otte <otte redhat com>
Date: Mon May 16 17:55:50 2011 +0200
cssprovider: Speed up gtk_widget_style_get() property lookups
Previously we got the list of all matching rules and then iterated it to
find the first one that had the property. Now we look while matching
rules, so we don't lookup rules that we don't need.
gtk/gtkcssprovider.c | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 9b5b4ba..ced8429 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1190,7 +1190,9 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
GParamSpec *pspec,
GValue *value)
{
- GArray *priority_info;
+ GtkCssProvider *css_provider = GTK_CSS_PROVIDER (provider);
+ GtkCssProviderPrivate *priv = css_provider->priv;
+ const GValue *val;
gboolean found = FALSE;
gchar *prop_name;
gint i;
@@ -1199,21 +1201,24 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
g_type_name (pspec->owner_type),
pspec->name);
- priority_info = css_provider_get_selectors (GTK_CSS_PROVIDER (provider), path);
-
- for (i = priority_info->len - 1; i >= 0; i--)
+ for (i = priv->selectors_info->len - 1; i >= 0; i--)
{
- StylePriorityInfo *info;
- GValue *val;
+ SelectorStyleInfo *info;
+ GtkStateFlags selector_state;
- info = &g_array_index (priority_info, StylePriorityInfo, i);
+ info = g_ptr_array_index (priv->selectors_info, i);
+
+ if (!_gtk_css_selector_matches (info->selector, path))
+ continue;
+
+ selector_state = _gtk_css_selector_get_state_flags (info->selector);
val = g_hash_table_lookup (info->style, prop_name);
if (val &&
- (info->state == 0 ||
- info->state == state ||
- ((info->state & state) != 0 &&
- (info->state & ~(state)) == 0)))
+ (selector_state == 0 ||
+ selector_state == state ||
+ ((selector_state & state) != 0 &&
+ (selector_state & ~(state)) == 0)))
{
GError *error = NULL;
@@ -1233,7 +1238,6 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
}
}
- g_array_free (priority_info, TRUE);
g_free (prop_name);
return found;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]