diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-09-10 20:42:58 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-09-12 11:24:43 -0400 |
commit | 83d68ea107bbeec96309608b6b18818d95ec35f9 (patch) | |
tree | ce4b579e71d6fca461c220f1fa6821d873176e7b /gtk/gtkcssselector.c | |
parent | a831f1fb112e342055428fc6ab8f825bb686a4b8 (diff) | |
download | gtk+-83d68ea107bbeec96309608b6b18818d95ec35f9.tar.gz |
css selector: Use a builtin to count bits
Diffstat (limited to 'gtk/gtkcssselector.c')
-rw-r--r-- | gtk/gtkcssselector.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c index aa279b2ade..66ab936886 100644 --- a/gtk/gtkcssselector.c +++ b/gtk/gtkcssselector.c @@ -746,15 +746,19 @@ gtk_css_selector_region_get_change (const GtkCssSelector *selector, GtkCssChange return previous_change | GTK_CSS_CHANGE_REGION; } -static guint +static inline guint count_bits (guint n) { +#if defined(__GNUC__) + return (guint) __builtin_popcount (n); +#else guint result = 0; for (result = 0; n != 0; result++) n &= n - 1; return result; +#endif } static void @@ -771,7 +775,7 @@ gtk_css_selector_region_add_specificity (const GtkCssSelector *selector, static guint gtk_css_selector_region_hash_one (const GtkCssSelector *a) { - return g_str_hash (a->region.name) ^ a->region.flags; + return GPOINTER_TO_UINT (a->region.name) ^ a->region.flags; } static int @@ -825,7 +829,12 @@ static int comp_class (const GtkCssSelector *a, const GtkCssSelector *b) { - return a->style_class.style_class - b->style_class.style_class; + if (a->style_class.style_class < b->style_class.style_class) + return -1; + if (a->style_class.style_class > b->style_class.style_class) + return 1; + else + return 0; } DEFINE_SIMPLE_SELECTOR(class, CLASS, print_class, match_class, hash_class, comp_class, FALSE, TRUE, FALSE) |