[gtk/wip/baedert/for-master: 24/29] csslookup: Remove 'missing' bitmask



commit 9a29355df8384ecaf9846de42873a6bb742c0ef2
Author: Timm Bäder <mail baedert org>
Date:   Thu Aug 22 18:00:37 2019 +0200

    csslookup: Remove 'missing' bitmask
    
    It's almost never useful to have a bitmask here, since it's only used
    for the intersection case in gtk_css_style_provider_lookup. However,
    even if that returns true, we still need to check every single style
    property for being set again in the look afterwards.
    
    Just remove the bitmask.

 gtk/gtkcsslookup.c        | 23 +++++++++--------------
 gtk/gtkcsslookupprivate.h | 13 ++-----------
 gtk/gtkcssprovider.c      |  8 ++------
 3 files changed, 13 insertions(+), 31 deletions(-)
---
diff --git a/gtk/gtkcsslookup.c b/gtk/gtkcsslookup.c
index b871c8f7a0..a595479162 100644
--- a/gtk/gtkcsslookup.c
+++ b/gtk/gtkcsslookup.c
@@ -29,22 +29,11 @@ _gtk_css_lookup_init (GtkCssLookup     *lookup,
                       const GtkBitmask *relevant)
 {
   memset (lookup, 0, sizeof (*lookup));
-
-  if (relevant)
-    {
-      lookup->missing = _gtk_bitmask_copy (relevant);
-    }
-  else
-    {
-      lookup->missing = _gtk_bitmask_new ();
-      lookup->missing = _gtk_bitmask_invert_range (lookup->missing, 0, GTK_CSS_PROPERTY_N_PROPERTIES);
-    }
 }
 
 void
 _gtk_css_lookup_destroy (GtkCssLookup *lookup)
 {
-  _gtk_bitmask_free (lookup->missing);
 }
 
 gboolean
@@ -53,7 +42,13 @@ _gtk_css_lookup_is_missing (const GtkCssLookup *lookup,
 {
   gtk_internal_return_val_if_fail (lookup != NULL, FALSE);
 
-  return _gtk_bitmask_get (lookup->missing, id);
+  return lookup->values[id].value == NULL;
+}
+
+gboolean
+_gtk_css_lookup_all_set (const GtkCssLookup *lookup)
+{
+  return lookup->n_set_values == GTK_CSS_PROPERTY_N_PROPERTIES;
 }
 
 /**
@@ -76,12 +71,12 @@ _gtk_css_lookup_set (GtkCssLookup  *lookup,
                      GtkCssValue   *value)
 {
   gtk_internal_return_if_fail (lookup != NULL);
-  gtk_internal_return_if_fail (_gtk_bitmask_get (lookup->missing, id));
   gtk_internal_return_if_fail (value != NULL);
+  gtk_internal_return_if_fail (lookup->values[id].value == NULL);
 
-  lookup->missing = _gtk_bitmask_set (lookup->missing, id, FALSE);
   lookup->values[id].value = value;
   lookup->values[id].section = section;
+  lookup->n_set_values ++;
 }
 
 /**
diff --git a/gtk/gtkcsslookupprivate.h b/gtk/gtkcsslookupprivate.h
index 5c8bbc96f1..0d6c1fc529 100644
--- a/gtk/gtkcsslookupprivate.h
+++ b/gtk/gtkcsslookupprivate.h
@@ -36,17 +36,16 @@ typedef struct {
 } GtkCssLookupValue;
 
 struct _GtkCssLookup {
-  GtkBitmask        *missing;
+  guint              n_set_values;
   GtkCssLookupValue  values[GTK_CSS_PROPERTY_N_PROPERTIES];
 };
 
 void                    _gtk_css_lookup_init                    (GtkCssLookup               *lookup,
                                                                  const GtkBitmask           *relevant);
 void                    _gtk_css_lookup_destroy                 (GtkCssLookup               *lookup);
-
-static inline const GtkBitmask *_gtk_css_lookup_get_missing     (const GtkCssLookup         *lookup);
 gboolean                _gtk_css_lookup_is_missing              (const GtkCssLookup         *lookup,
                                                                  guint                       id);
+gboolean                _gtk_css_lookup_all_set                 (const GtkCssLookup         *lookup);
 void                    _gtk_css_lookup_set                     (GtkCssLookup               *lookup,
                                                                  guint                       id,
                                                                  GtkCssSection              *section,
@@ -56,14 +55,6 @@ void                    _gtk_css_lookup_resolve                 (GtkCssLookup
                                                                  GtkCssStaticStyle          *style,
                                                                  GtkCssStyle                *parent_style);
 
-static inline const GtkBitmask *
-_gtk_css_lookup_get_missing (const GtkCssLookup *lookup)
-{
-  return lookup->missing;
-}
-
-
-
 G_END_DECLS
 
 #endif /* __GTK_CSS_LOOKUP_PRIVATE_H__ */
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 3ea1669b2d..32a098dc44 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -539,10 +539,6 @@ gtk_css_style_provider_lookup (GtkStyleProvider    *provider,
           if (ruleset->styles == NULL)
             continue;
 
-          if (!_gtk_bitmask_intersects (_gtk_css_lookup_get_missing (lookup),
-                                        ruleset->set_styles))
-          continue;
-
           for (j = 0; j < ruleset->n_styles; j++)
             {
               GtkCssStyleProperty *prop = ruleset->styles[j].property;
@@ -554,10 +550,10 @@ gtk_css_style_provider_lookup (GtkStyleProvider    *provider,
               _gtk_css_lookup_set (lookup,
                                    id,
                                    ruleset->styles[j].section,
-                                  ruleset->styles[j].value);
+                                   ruleset->styles[j].value);
             }
 
-          if (_gtk_bitmask_is_empty (_gtk_css_lookup_get_missing (lookup)))
+          if (_gtk_css_lookup_all_set (lookup))
             break;
         }
 


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