[gtk+] izegroup: Improve performance
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] izegroup: Improve performance
- Date: Sun, 25 Nov 2012 12:32:56 +0000 (UTC)
commit 2ab65ef771616e427db6417815359229faa0beb9
Author: Benjamin Otte <otte redhat com>
Date: Sun Nov 25 13:32:21 2012 +0100
izegroup: Improve performance
Keep a list of all groups and avoid groups we already handled. Speeds up
GtkToolpalette a lot.
gtk/gtksizegroup.c | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtksizegroup.c b/gtk/gtksizegroup.c
index 7c57558..a9ae863 100644
--- a/gtk/gtksizegroup.c
+++ b/gtk/gtksizegroup.c
@@ -152,17 +152,18 @@ G_STATIC_ASSERT (GTK_SIZE_GROUP_VERTICAL == (1 << GTK_ORIENTATION_VERTICAL));
G_STATIC_ASSERT (GTK_SIZE_GROUP_BOTH == (GTK_SIZE_GROUP_HORIZONTAL | GTK_SIZE_GROUP_VERTICAL));
static void
-add_widget_to_closure (GHashTable *set,
+add_widget_to_closure (GHashTable *widgets,
+ GHashTable *groups,
GtkWidget *widget,
GtkOrientation orientation)
{
GSList *tmp_groups, *tmp_widgets;
gboolean hidden;
- if (g_hash_table_lookup (set, widget))
+ if (g_hash_table_lookup (widgets, widget))
return;
- g_hash_table_insert (set, widget, widget);
+ g_hash_table_insert (widgets, widget, widget);
hidden = !gtk_widget_is_visible (widget);
for (tmp_groups = _gtk_widget_get_sizegroups (widget); tmp_groups; tmp_groups = tmp_groups->next)
@@ -170,14 +171,19 @@ add_widget_to_closure (GHashTable *set,
GtkSizeGroup *tmp_group = tmp_groups->data;
GtkSizeGroupPrivate *tmp_priv = tmp_group->priv;
+ if (g_hash_table_lookup (groups, tmp_group))
+ continue;
+
if (tmp_priv->ignore_hidden && hidden)
continue;
if (!(tmp_priv->mode & (1 << orientation)))
continue;
+ g_hash_table_insert (groups, tmp_group, tmp_group);
+
for (tmp_widgets = tmp_priv->widgets; tmp_widgets; tmp_widgets = tmp_widgets->next)
- add_widget_to_closure (set, tmp_widgets->data, orientation);
+ add_widget_to_closure (widgets, groups, tmp_widgets->data, orientation);
}
}
@@ -185,13 +191,16 @@ GHashTable *
_gtk_size_group_get_widget_peers (GtkWidget *for_widget,
GtkOrientation orientation)
{
- GHashTable *result;
+ GHashTable *widgets, *groups;
+
+ widgets = g_hash_table_new (g_direct_hash, g_direct_equal);
+ groups = g_hash_table_new (g_direct_hash, g_direct_equal);
- result = g_hash_table_new (g_direct_hash, g_direct_equal);
+ add_widget_to_closure (widgets, groups, for_widget, orientation);
- add_widget_to_closure (result, for_widget, orientation);
+ g_hash_table_unref (groups);
- return result;
+ return widgets;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]