iconview: Don't cache iters

This is a huge quest to remove all caching from GtkIconview to simplify
the code. As it turns out, iconview performance is a joke, so the caches
are kinda unnecessary.

If we need caching, we can add it in a useful way later.
This commit is contained in:
Benjamin Otte 2012-05-04 18:44:39 +02:00
parent ee91e272a8
commit 63ddb3f2c7
2 changed files with 5 additions and 27 deletions

View File

@ -3186,22 +3186,16 @@ gtk_icon_view_row_inserted (GtkTreeModel *model,
GtkIconView *icon_view = GTK_ICON_VIEW (data); GtkIconView *icon_view = GTK_ICON_VIEW (data);
gint index; gint index;
GtkIconViewItem *item; GtkIconViewItem *item;
gboolean iters_persist;
GList *list; GList *list;
/* ignore changes in branches */ /* ignore changes in branches */
if (gtk_tree_path_get_depth (path) > 1) if (gtk_tree_path_get_depth (path) > 1)
return; return;
iters_persist = gtk_tree_model_get_flags (icon_view->priv->model) & GTK_TREE_MODEL_ITERS_PERSIST;
index = gtk_tree_path_get_indices(path)[0]; index = gtk_tree_path_get_indices(path)[0];
item = gtk_icon_view_item_new (); item = gtk_icon_view_item_new ();
if (iters_persist)
item->iter = *iter;
item->index = index; item->index = index;
/* FIXME: We can be more efficient here, /* FIXME: We can be more efficient here,
@ -3330,11 +3324,8 @@ gtk_icon_view_build_items (GtkIconView *icon_view)
{ {
GtkTreeIter iter; GtkTreeIter iter;
int i; int i;
gboolean iters_persist;
GList *items = NULL; GList *items = NULL;
iters_persist = gtk_tree_model_get_flags (icon_view->priv->model) & GTK_TREE_MODEL_ITERS_PERSIST;
if (!gtk_tree_model_get_iter_first (icon_view->priv->model, if (!gtk_tree_model_get_iter_first (icon_view->priv->model,
&iter)) &iter))
return; return;
@ -3345,9 +3336,6 @@ gtk_icon_view_build_items (GtkIconView *icon_view)
{ {
GtkIconViewItem *item = gtk_icon_view_item_new (); GtkIconViewItem *item = gtk_icon_view_item_new ();
if (iters_persist)
item->iter = iter;
item->index = i; item->index = i;
i++; i++;
@ -4075,22 +4063,13 @@ void
_gtk_icon_view_set_cell_data (GtkIconView *icon_view, _gtk_icon_view_set_cell_data (GtkIconView *icon_view,
GtkIconViewItem *item) GtkIconViewItem *item)
{ {
gboolean iters_persist;
GtkTreeIter iter; GtkTreeIter iter;
GtkTreePath *path;
iters_persist = gtk_tree_model_get_flags (icon_view->priv->model) & GTK_TREE_MODEL_ITERS_PERSIST; path = gtk_tree_path_new_from_indices (item->index, -1);
if (!gtk_tree_model_get_iter (icon_view->priv->model, &iter, path))
if (!iters_persist) return;
{ gtk_tree_path_free (path);
GtkTreePath *path;
path = gtk_tree_path_new_from_indices (item->index, -1);
if (!gtk_tree_model_get_iter (icon_view->priv->model, &iter, path))
return;
gtk_tree_path_free (path);
}
else
iter = item->iter;
gtk_cell_area_apply_attributes (icon_view->priv->cell_area, gtk_cell_area_apply_attributes (icon_view->priv->cell_area,
icon_view->priv->model, icon_view->priv->model,

View File

@ -25,7 +25,6 @@ struct _GtkIconViewItem
{ {
GdkRectangle cell_area; GdkRectangle cell_area;
GtkTreeIter iter;
gint index; gint index;
gint row, col; gint row, col;