[gtk+/parser: 3/18] cssprovider: Use g_type_depth() instead of computing the depth manually



commit 8d4ded48e12bdbafe02d0ce53c0e5c104d11f76c
Author: Benjamin Otte <otte redhat com>
Date:   Sat Apr 2 00:03:18 2011 +0200

    cssprovider: Use g_type_depth() instead of computing the depth manually

 gtk/gtkcssprovider.c |   20 ++++++--------------
 1 files changed, 6 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 9557a33..de29766 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1138,23 +1138,15 @@ compare_selector_element (GtkWidgetPath   *path,
         *score |= 0xF;
       else
         {
-          GType parent = type;
+          guint diff = g_type_depth (type) - g_type_depth (elem->type);
 
-          *score = 0xE;
-
-          while ((parent = g_type_parent (parent)) != G_TYPE_INVALID)
+          if (G_UNLIKELY (diff > 0xE))
             {
-              if (parent == elem->type)
-                break;
-
-              *score -= 1;
-
-              if (*score == 1)
-                {
-                  g_warning ("Hierarchy is higher than expected.");
-                  break;
-                }
+              g_warning ("Hierarchy is higher than expected.");
+              diff = 0xE;
             }
+          
+          *score = 0XF - diff;
         }
 
       return TRUE;



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