Commit 0f635335 authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

Slightly modified patch from Owen Taylor <otaylor@redhat.com> to improve

Wed Jun  4 19:22:58 2003  Jonathan Blandford  <jrb@redhat.com>

        * gtk/gtktreemodelsort.c (gtk_tree_model_sort_level_find_insert):
        Slightly modified patch from Owen Taylor <otaylor@redhat.com> to
        improve the speed of inserting rows into an already sorted list,
        #109292
parent 76fc08a3
Wed Jun 4 19:22:58 2003 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_level_find_insert):
Slightly modified patch from Owen Taylor <otaylor@redhat.com> to
improve the speed of inserting rows into an already sorted list,
#109292
Wed Jun 4 19:24:28 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkgc-x11.c gdk/x11/gdkprivate-x11.h: Keep
......
Wed Jun 4 19:22:58 2003 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_level_find_insert):
Slightly modified patch from Owen Taylor <otaylor@redhat.com> to
improve the speed of inserting rows into an already sorted list,
#109292
Wed Jun 4 19:24:28 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkgc-x11.c gdk/x11/gdkprivate-x11.h: Keep
......
Wed Jun 4 19:22:58 2003 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_level_find_insert):
Slightly modified patch from Owen Taylor <otaylor@redhat.com> to
improve the speed of inserting rows into an already sorted list,
#109292
Wed Jun 4 19:24:28 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkgc-x11.c gdk/x11/gdkprivate-x11.h: Keep
......
Wed Jun 4 19:22:58 2003 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_level_find_insert):
Slightly modified patch from Owen Taylor <otaylor@redhat.com> to
improve the speed of inserting rows into an already sorted list,
#109292
Wed Jun 4 19:24:28 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkgc-x11.c gdk/x11/gdkprivate-x11.h: Keep
......
Wed Jun 4 19:22:58 2003 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_level_find_insert):
Slightly modified patch from Owen Taylor <otaylor@redhat.com> to
improve the speed of inserting rows into an already sorted list,
#109292
Wed Jun 4 19:24:28 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkgc-x11.c gdk/x11/gdkprivate-x11.h: Keep
......
......@@ -485,12 +485,9 @@ gtk_tree_model_sort_row_changed (GtkTreeModel *s_model,
for (i = 0; i < level->array->len; i++)
if (elt->offset == g_array_index (level->array, SortElt, i).offset)
index = i;
old_index = i;
memcpy (&tmp, elt, sizeof (SortElt));
g_array_remove_index (level->array, index);
old_index = index;
if (GTK_TREE_MODEL_SORT_CACHE_CHILD_ITERS (tree_model_sort))
index = gtk_tree_model_sort_level_find_insert (tree_model_sort,
......@@ -503,7 +500,20 @@ gtk_tree_model_sort_row_changed (GtkTreeModel *s_model,
&tmpiter,
TRUE);
g_array_insert_val (level->array, index, tmp);
if (index < old_index)
{
g_memmove (level->array->data + ((index + 1)*sizeof (SortElt)),
level->array->data + ((index)*sizeof (SortElt)),
(old_index - index)* sizeof(SortElt));
}
else if (index > old_index)
{
g_memmove (level->array->data + ((old_index)*sizeof (SortElt)),
level->array->data + ((old_index + 1)*sizeof (SortElt)),
(index - old_index)* sizeof(SortElt));
}
memcpy (level->array->data + ((index)*sizeof (SortElt)),
&tmp, sizeof (SortElt));
for (i = 0; i < level->array->len; i++)
if (g_array_index (level->array, SortElt, i).children)
......@@ -1663,7 +1673,8 @@ gtk_tree_model_sort_level_find_insert (GtkTreeModelSort *tree_model_sort,
GtkTreeIter *iter,
gboolean skip_sort_elt)
{
gint middle;
gint start, middle, end;
gint skip_index;
gint cmp;
SortElt *tmp_elt;
GtkTreeIter tmp_iter;
......@@ -1671,8 +1682,6 @@ gtk_tree_model_sort_level_find_insert (GtkTreeModelSort *tree_model_sort,
GtkTreeIterCompareFunc func;
gpointer data;
GtkTreePath *path;
if (tree_model_sort->sort_column_id != GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID)
{
GtkTreeDataSortHeader *header;
......@@ -1694,19 +1703,39 @@ gtk_tree_model_sort_level_find_insert (GtkTreeModelSort *tree_model_sort,
}
g_return_val_if_fail (func != NULL, 0);
for (middle = 0; middle < level->array->len; middle++)
{
tmp_elt = &(g_array_index (level->array, SortElt, middle));
if (!skip_sort_elt && SORT_ELT (iter->user_data2) == tmp_elt)
continue;
start = 0;
end = level->array->len;
if (skip_sort_elt)
{
skip_index = SORT_ELT (iter->user_data2) - SORT_ELT (level->array->data);
end--;
}
else
skip_index = end;
path = gtk_tree_model_sort_elt_get_path (level, tmp_elt);
gtk_tree_model_get_iter (tree_model_sort->child_model,
&tmp_iter, path);
gtk_tree_path_free (path);
if (start == end)
return 0;
while (start != end)
{
middle = (start + end) / 2;
if (middle < skip_index)
tmp_elt = &(g_array_index (level->array, SortElt, middle));
else
tmp_elt = &(g_array_index (level->array, SortElt, middle + 1));
if (!GTK_TREE_MODEL_SORT_CACHE_CHILD_ITERS (tree_model_sort))
{
GtkTreePath *path = gtk_tree_model_sort_elt_get_path (level, tmp_elt);
gtk_tree_model_get_iter (tree_model_sort->child_model,
&tmp_iter, path);
gtk_tree_path_free (path);
}
else
tmp_iter = tmp_elt->iter;
if (tree_model_sort->order == GTK_SORT_ASCENDING)
cmp = (* func) (GTK_TREE_MODEL (tree_model_sort->child_model),
&tmp_iter, iter, data);
......@@ -1714,11 +1743,16 @@ gtk_tree_model_sort_level_find_insert (GtkTreeModelSort *tree_model_sort,
cmp = (* func) (GTK_TREE_MODEL (tree_model_sort->child_model),
iter, &tmp_iter, data);
if (cmp > 0)
break;
if (cmp <= 0)
start = middle + 1;
else
end = middle;
}
return middle;
if (cmp <= 0)
return middle + 1;
else
return middle;
}
static gboolean
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment