GtkTreeView: inserting rows faster.



Hi All,

I've been trying to improve the performance of inserting new rows
into a GtkTreeView. The performance is somewhat lacking. I am calling
gtk_list_store_insert_after(), to try to avoid linear searches through
existing rows, but it's not having the desired effect.

There are two areas where things could probably be improved. I'm not
all that familiar with gtk's source, so you might want to correct me
here and there:

GtkListStore:
~~~~~~~~~~~~~

In gtk_list_store_append_after() there is a loop that could be
elimintated:

  for (list = list_store->root; list && list != sibling->user_data; list =
list->next)
    i++;

We'd need to change ListStore to use doubly linked lists, so it would
take 4 bytes extra memory per row on x86.

list_store_append_after() also calls gtk_tree_model_row_inserted, which
in turn calls gtk_list_store_get_path(). There's another linear loop here:

  for (list = G_SLIST (GTK_LIST_STORE (tree_model)->root); list; list =
list->next)

gtk_tree_path_append_index is called 2 times at least, that's 2 realloc()s.
This could probably be optimized too.

gtk_tree_row_ref_inserted_callback has another linear loop.


GtkTreeView:
~~~~~~~~~~~~

It redraws even when the newly inserted row is not visible. I havn't
looked at this code at all yet.



That's about I can see that could potentially be improved, from a quick
scan through the source. I'd like to hear some comments from people more
familiar with the code.

Ideally, it should be possible to insert rows in constant time when
calling gtk_list_store_insert_(after/before). Is it achievable?



-- 
Peter Zelezny.



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