From 0a23796f5de659be38618300b5c8eb4a0cb0afb1 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 2 Apr 2011 00:03:18 +0200 Subject: [PATCH] cssprovider: Use g_type_depth() instead of computing the depth manually --- gtk/gtkcssprovider.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index facac8a5bc..a9331575f9 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;