[gtk/css-lookup-caching: 22/26] Revert "wip: Count duplicate lookups"



commit a956c54f06526ed357ca78d6a08a950c5008d5ea
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Feb 11 19:03:16 2020 -0500

    Revert "wip: Count duplicate lookups"
    
    This reverts commit c23cd3574dcc301b2f1fbbfb4fd83941da7aea25.

 gtk/gtkcsslookup.c        | 113 ----------------------------------------------
 gtk/gtkcsslookupprivate.h |   2 -
 gtk/gtkcssstaticstyle.c   |   2 -
 3 files changed, 117 deletions(-)
---
diff --git a/gtk/gtkcsslookup.c b/gtk/gtkcsslookup.c
index 8be44da66f..7e52359b65 100644
--- a/gtk/gtkcsslookup.c
+++ b/gtk/gtkcsslookup.c
@@ -25,77 +25,6 @@
 #include "gtkprivate.h"
 
 
-static GHashTable *lookups;
-
-static gboolean
-gtk_css_lookup_equal (const GtkCssLookup *l1,
-                      const GtkCssLookup *l2)
-{
-  int i;
-
-  if (!_gtk_bitmask_equals (l1->set_values, l2->set_values))
-    return FALSE;
-
-  if (l1->values == NULL && l2->values == NULL)
-    return TRUE;
-
-  if (l1->values == NULL || l2->values == NULL)
-    return FALSE;
-
-  if (l1->values->len != l2->values->len)
-    return FALSE;
-
-  for (i = 0; i < l1->values->len; i++)
-    {
-      GtkCssLookupValue *v1 = g_ptr_array_index (l1->values, i);
-      GtkCssLookupValue *v2 = g_ptr_array_index (l2->values, i);
-
-      if (!_gtk_css_value_equal (v1->value, v2->value))
-        return FALSE;
-    }
-
-  return TRUE;
-}
-
-static guint
-gtk_css_lookup_hash (const GtkCssLookup *l)
-{
-  int i;
-  guint h;
-
-  if (l->values == NULL)
-    return 0;
-
-  h = 0;
-  for (i = 0; i < l->values->len; i++)
-    {
-      GtkCssLookupValue *v = g_ptr_array_index (l->values, i);
-      char *s = _gtk_css_value_to_string (v->value);
-      h += g_str_hash (s);
-      g_free (s);
-    }
-
-  return h;
-}
-
-static gboolean
-dump_lookups (gpointer data)
-{
-  GHashTableIter iter;
-  GtkCssLookup *key;
-  gpointer value;
-
-  g_print ("lookup counts: ");
-  g_hash_table_iter_init (&iter, lookups);
-  while (g_hash_table_iter_next (&iter, (gpointer *)&key, (gpointer *)&value))
-    {
-      g_print ("%d ", GPOINTER_TO_INT (value));
-    }
-  g_print ("\n");
-
-  return G_SOURCE_CONTINUE;
-}
-
 GtkCssLookup *
 gtk_css_lookup_new (void)
 {
@@ -104,50 +33,12 @@ gtk_css_lookup_new (void)
   lookup->ref_count = 1;
   lookup->set_values = _gtk_bitmask_new ();
 
-  if (!lookups)
-    {
-      lookups = g_hash_table_new (gtk_css_lookup_hash, gtk_css_lookup_equal);
-      g_timeout_add (1000, dump_lookups, NULL);
-    }
-
   return lookup;
 }
 
-void
-gtk_css_lookup_register (GtkCssLookup *lookup)
-{
-  gint count;
-
-  count = GPOINTER_TO_INT (g_hash_table_lookup (lookups, lookup));
-  count++;
-
-  if (count == 1)
-    gtk_css_lookup_ref (lookup);
-
-  g_hash_table_insert (lookups, lookup, GINT_TO_POINTER (count));
-}
-
-static void
-gtk_css_lookup_unregister (GtkCssLookup *lookup)
-{
-  gint count;
-
-  count = GPOINTER_TO_INT (g_hash_table_lookup (lookups, lookup));
-  g_assert (count > 0);
-  if (count == 1)
-    g_hash_table_remove (lookups, lookup);
-  else
-    {
-      count--;
-      g_hash_table_insert (lookups, lookup, GINT_TO_POINTER (count));
-    }
-}
-
 static void
 gtk_css_lookup_free (GtkCssLookup *lookup)
 {
-  gtk_css_lookup_unregister (lookup);
-
   _gtk_bitmask_free (lookup->set_values);
   if (lookup->values)
     g_ptr_array_unref (lookup->values);
@@ -173,10 +64,6 @@ gtk_css_lookup_unref (GtkCssLookup *lookup)
 
   lookup->ref_count--;
 
-  if (lookup->ref_count == 1 &&
-      GPOINTER_TO_INT (g_hash_table_lookup (lookups, lookup)) == 1)
-    lookup->ref_count--;
-
   if (lookup->ref_count == 0)
     gtk_css_lookup_free (lookup);
 }
diff --git a/gtk/gtkcsslookupprivate.h b/gtk/gtkcsslookupprivate.h
index d2dd82cee4..f73d8f56de 100644
--- a/gtk/gtkcsslookupprivate.h
+++ b/gtk/gtkcsslookupprivate.h
@@ -77,8 +77,6 @@ gtk_css_lookup_get (GtkCssLookup *lookup,
   return NULL;
 } 
 
-void gtk_css_lookup_register (GtkCssLookup *lookup);
-
 G_END_DECLS
 
 #endif /* __GTK_CSS_LOOKUP_PRIVATE_H__ */
diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c
index d4c1df6b19..8ccc1fe9f0 100644
--- a/gtk/gtkcssstaticstyle.c
+++ b/gtk/gtkcssstaticstyle.c
@@ -993,8 +993,6 @@ gtk_css_static_style_new_compute (GtkStyleProvider             *provider,
                                    node,
                                    lookup,
                                    change == 0 ? &change : NULL);
-
-      gtk_css_lookup_register (lookup);
     }
 
   result = g_object_new (GTK_TYPE_CSS_STATIC_STYLE, NULL);


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