[gtk+] gtk_css_style_provider_lookup: minor loop optimiziation



commit 1c4158a6491e219f6b50c92c069bf432bda9f13c
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Nov 9 10:06:55 2012 +0100

    gtk_css_style_provider_lookup: minor loop optimiziation
    
    This is a minor performance improvement but this loop
    is run a lot so it actually matters in large state
    changes.

 gtk/gtkcssprovider.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index fbf9970..8be9d23 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1568,18 +1568,19 @@ gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
 {
   GtkCssProvider *css_provider;
   GtkCssProviderPrivate *priv;
-  int i;
+  GtkCssRuleset *ruleset;
   guint j;
 
   css_provider = GTK_CSS_PROVIDER (provider);
   priv = css_provider->priv;
 
-  for (i = priv->rulesets->len - 1; i >= 0; i--)
-    {
-      GtkCssRuleset *ruleset;
-
-      ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
+  if (priv->rulesets->len == 0)
+    return;
 
+  for (ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, priv->rulesets->len - 1);
+       ruleset >= &g_array_index (priv->rulesets, GtkCssRuleset, 0);
+       ruleset--)
+    {
       if (ruleset->styles == NULL)
         continue;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]