On Thu, 12 Jun 2003, Petnuch, Michael wrote: > I am having performance problems with GtkListStore. I am adding around say > 500 rows all of which are being updated constantly. I do: I bet this error is the same that I was helped in just a few days ago. I submitted a documentation bug for it: http://bugzilla.gnome.org/show_bug.cgi?id=114657 ----------------- Document sorting behaviour for gtk_tree_sortable_set_sort_column_id () Information from the gtk-list gives at hand that invoking this function under certain circumstances has some undesired side effects. I propose adding the following text to the manual section on GtkSortable or in the FAQ: Calling gtk_tree_sortable_set_sort_column_id() on a certain GtkTreeStore or GtkListStore will turn on sorting for this list store. This will slow down performance on subsequent data additions from O(n) to O(n^2). There is no way to turn sorting off again. If you repeatedly add several (say thousands) of rows to a tree or list store, this will cause a noticable delay. Therefore, if you desire large, sorted lists and trees, the procedure to follow when filling the store anew is: 1. Create a new list store with gtk_list_store_new() 2. Replace it for the one currently connected to your view with gtk_tree_view_set_model() 3. Invoke g_object_unref() on the old store and destroy it. 4. Fill the new store with some thousand entries. 5. Turn sorting back on using gtk_tree_sortable_set_sort_column_id() -------------------- That said, I can think up algorithms that should be able to do addition in O(n log n) or so, but probably GTK should eventually be improved with a fuction like the freeze() of CList that can temporarily turn off sorting and then turn it back on again after adding rows. I don't know how that matches with the GTK architecture though. Linus