From aa1899af14ef8c2792b5c25b3aef6f5b6a9a92ac Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Mon, 29 Oct 2001 20:36:24 +0000 Subject: Don't go outside the table looking for matches when doing the last_access 2001-10-29 Christopher James Lahey * e-table-subset.c (etss_get_view_row), e-tree-sorted.c (check_last_access), e-tree-table-adapter.c (find_row_num): Don't go outside the table looking for matches when doing the last_access search. svn path=/trunk/; revision=14359 --- widgets/table/e-tree-sorted.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'widgets/table/e-tree-sorted.c') diff --git a/widgets/table/e-tree-sorted.c b/widgets/table/e-tree-sorted.c index 25e82738fb..f86bca0a06 100644 --- a/widgets/table/e-tree-sorted.c +++ b/widgets/table/e-tree-sorted.c @@ -164,9 +164,6 @@ check_last_access (ETreeSorted *ets, ETreePath corresponding) { #ifdef CHECK_AROUND_LAST_ACCESS ETreeSortedPath *parent; - int end; - int start; - int i; #endif if (ets->priv->last_access == NULL) @@ -180,18 +177,20 @@ check_last_access (ETreeSorted *ets, ETreePath corresponding) #ifdef CHECK_AROUND_LAST_ACCESS parent = ets->priv->last_access->parent; if (parent && parent->children) { - i = ets->priv->last_access->position; - end = MIN(parent->num_children, i + 10); - for (; i < end; i++) { + int position = ets->priv->last_access->position; + int end = MIN(parent->num_children, position + 10); + int start = MAX(0, position - 10); + int initial = MAX (MIN (position, end), start); + int i; + + for (i = initial + 1; i < end; i++) { if (parent->children[i] && parent->children[i]->corresponding == corresponding) { d(g_print("Found last access %p at %p.", ets->priv->last_access, parent->children[i])); return parent->children[i]; } } - i = ets->priv->last_access->position - 1; - start = MAX(0, i - 10); - for (; i >= start; i--) { + for (i = initial - 1; i >= start; i--) { if (parent->children[i] && parent->children[i]->corresponding == corresponding) { d(g_print("Found last access %p at %p.", ets->priv->last_access, parent->children[i])); return parent->children[i]; -- cgit v1.2.3