Revision: 5558 http://geany.svn.sourceforge.net/geany/?rev=5558&view=rev Author: colombanw Date: 2011-03-05 22:47:13 +0000 (Sat, 05 Mar 2011)
Log Message: ----------- Improve implementation of hide_empty_rows() to do all in one shot
Modified Paths: -------------- trunk/src/symbols.c
Modified: trunk/src/symbols.c =================================================================== --- trunk/src/symbols.c 2011-03-05 22:46:32 UTC (rev 5557) +++ trunk/src/symbols.c 2011-03-05 22:47:13 UTC (rev 5558) @@ -900,30 +900,21 @@ }
-/* the following code surely can be improved, at the moment it collects some iters - * for removal and after that the actual removal is done. I didn't find a way to find and remove - * an empty row in one loop (next iter fails then) */ +/* removes toplevel items that have no children */ static void hide_empty_rows(GtkTreeStore *store) { - GtkTreeIter iter, *iters[MAX_SYMBOL_TYPES] = { NULL }; - guint i = 0; + GtkTreeIter iter; + gboolean cont = TRUE;
if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) return; /* stop when first iter is invalid, i.e. no elements */
- do /* first collect the iters we need to delete empty rows */ + while (cont) { if (! gtk_tree_model_iter_has_child(GTK_TREE_MODEL(store), &iter)) - iters[i++] = gtk_tree_iter_copy(&iter); - } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter)); - - /* now actually delete the collected iters */ - for (i = 0; i < MAX_SYMBOL_TYPES; i++) - { - if (G_UNLIKELY(iters[i] == NULL)) - break; - gtk_tree_store_remove(store, iters[i]); - gtk_tree_iter_free(iters[i]); + cont = gtk_tree_store_remove(store, &iter); + else + cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); } }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.