[gtk/css-lookup-caching: 13/26] style: Cache the lookup



commit 14319dcff31db4ddc7aa47b11ca7ea0a47b50b55
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Feb 10 18:40:50 2020 -0500

    style: Cache the lookup
    
    This is not used for anything yet.

 gtk/gtkcssstaticstyle.c        | 13 +++++++++++--
 gtk/gtkcssstaticstyleprivate.h |  3 +++
 2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c
index c1ecbe4e97..a71a47d0b5 100644
--- a/gtk/gtkcssstaticstyle.c
+++ b/gtk/gtkcssstaticstyle.c
@@ -322,6 +322,8 @@ gtk_css_static_style_dispose (GObject *object)
       style->sections = NULL;
     }
 
+  g_clear_pointer (&style->lookup, gtk_css_lookup_unref);
+
   G_OBJECT_CLASS (gtk_css_static_style_parent_class)->dispose (object);
 }
 
@@ -1008,6 +1010,7 @@ gtk_css_static_style_new_compute (GtkStyleProvider             *provider,
 
   result = g_object_new (GTK_TYPE_CSS_STATIC_STYLE, NULL);
 
+  result->lookup = lookup;
   result->change = change;
 
   if (node)
@@ -1020,8 +1023,6 @@ gtk_css_static_style_new_compute (GtkStyleProvider             *provider,
                           result,
                           parent ? gtk_css_node_get_style (parent) : NULL);
 
-  gtk_css_lookup_unref (lookup);
-
   return GTK_CSS_STYLE (result);
 }
 
@@ -1099,3 +1100,11 @@ gtk_css_static_style_get_change (GtkCssStaticStyle *style)
 
   return style->change;
 }
+
+GtkCssLookup *
+gtk_css_static_style_get_lookup (GtkCssStaticStyle *style)
+{
+  g_return_val_if_fail (GTK_IS_CSS_STATIC_STYLE (style), NULL);
+
+  return style->lookup;
+}
diff --git a/gtk/gtkcssstaticstyleprivate.h b/gtk/gtkcssstaticstyleprivate.h
index 04654ac070..0244c8ee44 100644
--- a/gtk/gtkcssstaticstyleprivate.h
+++ b/gtk/gtkcssstaticstyleprivate.h
@@ -23,6 +23,7 @@
 #include "gtk/gtkcssstyleprivate.h"
 
 #include "gtk/gtkcountingbloomfilterprivate.h"
+#include "gtk/gtkcsslookupprivate.h"
 
 G_BEGIN_DECLS
 
@@ -43,6 +44,7 @@ struct _GtkCssStaticStyle
   GPtrArray             *sections;             /* sections the values are defined in */
 
   GtkCssChange           change;               /* change as returned by value lookup */
+  GtkCssLookup          *lookup;
 };
 
 struct _GtkCssStaticStyleClass
@@ -58,6 +60,7 @@ GtkCssStyle *           gtk_css_static_style_new_compute        (GtkStyleProvide
                                                                  GtkCssNode                     *node,
                                                                  GtkCssChange                    change);
 GtkCssChange            gtk_css_static_style_get_change         (GtkCssStaticStyle              *style);
+GtkCssLookup *          gtk_css_static_style_get_lookup         (GtkCssStaticStyle              *style);
 
 G_END_DECLS
 


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