[gtk+] GtkIconTheme: Stop using the all_icons hash table



commit 11ec8f7285e2640e86e0570c60ca47763e138f0b
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jun 19 21:37:01 2014 -0400

    GtkIconTheme: Stop using the all_icons hash table
    
    This hash table was used in gtk_icon_theme_has_icon; we can
    implement that function just as well without it and save some
    memory.

 gtk/gtkicontheme.c |   35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index b42bf83..8bdda09 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -334,6 +334,8 @@ static GtkIconInfo *theme_lookup_icon         (IconTheme        *theme,
 static void         theme_list_icons          (IconTheme        *theme,
                                                GHashTable       *icons,
                                                GQuark            context);
+static gboolean     theme_has_icon            (IconTheme        *theme,
+                                               const gchar      *icon_name);
 static void         theme_list_contexts       (IconTheme        *theme,
                                                GHashTable       *contexts);
 static void         theme_subdir_load         (GtkIconTheme     *icon_theme,
@@ -2326,9 +2328,11 @@ gtk_icon_theme_has_icon (GtkIconTheme *icon_theme,
         return TRUE;
     }
 
-  if (g_hash_table_lookup_extended (priv->all_icons,
-                                    icon_name, NULL, NULL))
-    return TRUE;
+  for (l = priv->themes; l; l = l->next)
+    {
+      if (theme_has_icon (l->data, icon_name))
+        return TRUE;
+    }
 
   if (icon_theme_builtin_icons &&
       g_hash_table_lookup_extended (icon_theme_builtin_icons,
@@ -2990,6 +2994,31 @@ theme_list_icons (IconTheme  *theme,
     }
 }
 
+static gboolean
+theme_has_icon (IconTheme   *theme,
+                const gchar *icon_name)
+{
+  GList *l;
+
+  for (l = theme->dirs; l; l = l->next)
+    {
+      IconThemeDir *dir = l->data;
+
+      if (dir->cache)
+        {
+          if (_gtk_icon_cache_has_icon (dir->cache, icon_name))
+            return TRUE;
+        }
+      else
+        {
+          if (g_hash_table_lookup (dir->icons, icon_name) != NULL)
+            return TRUE;
+        }
+    }
+
+  return FALSE;
+}
+
 static void
 theme_list_contexts (IconTheme  *theme, 
                      GHashTable *contexts)


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