aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-10-30 04:36:24 +0800
committerChris Lahey <clahey@src.gnome.org>2001-10-30 04:36:24 +0800
commitaa1899af14ef8c2792b5c25b3aef6f5b6a9a92ac (patch)
treef479642f4b221fdf278578624c2dc71e04425a51 /widgets
parentf828accd314674f31de652bf4cd5d0b5e136f9ab (diff)
downloadgsoc2013-evolution-aa1899af14ef8c2792b5c25b3aef6f5b6a9a92ac.tar.gz
gsoc2013-evolution-aa1899af14ef8c2792b5c25b3aef6f5b6a9a92ac.tar.zst
gsoc2013-evolution-aa1899af14ef8c2792b5c25b3aef6f5b6a9a92ac.zip
Don't go outside the table looking for matches when doing the last_access
2001-10-29 Christopher James Lahey <clahey@ximian.com> * 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
Diffstat (limited to 'widgets')
-rw-r--r--widgets/table/e-table-subset.c11
-rw-r--r--widgets/table/e-tree-sorted.c17
-rw-r--r--widgets/table/e-tree-table-adapter.c5
3 files changed, 17 insertions, 16 deletions
diff --git a/widgets/table/e-table-subset.c b/widgets/table/e-table-subset.c
index d37e35d22b..a55f9b4b0f 100644
--- a/widgets/table/e-table-subset.c
+++ b/widgets/table/e-table-subset.c
@@ -43,13 +43,15 @@ static ETableModelClass *etss_parent_class;
static gint
etss_get_view_row (ETableSubset *etss, int row)
{
- int limit;
const int n = etss->n_map;
const int * const map_table = etss->map_table;
int i;
- limit = MIN(n, etss->last_access + 10);
- for (i = etss->last_access; i < limit; i++) {
+ int end = MIN(etss->n_map, etss->last_access + 10);
+ int start = MAX(0, etss->last_access - 10);
+ int initial = MAX (MIN (etss->last_access, end), start);
+
+ for (i = initial; i < end; i++) {
if (map_table [i] == row){
d(g_print("a) Found %d from %d\n", i, etss->last_access));
etss->last_access = i;
@@ -57,8 +59,7 @@ etss_get_view_row (ETableSubset *etss, int row)
}
}
- limit = MAX(0, etss->last_access - 10);
- for (i = etss->last_access - 1; i >= limit; i--) {
+ for (i = initial - 1; i >= start; i--) {
if (map_table [i] == row){
e_table_model_row_changed (E_TABLE_MODEL (etss), i);
d(g_print("b) Found %d from %d\n", i, etss->last_access));
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];
diff --git a/widgets/table/e-tree-table-adapter.c b/widgets/table/e-tree-table-adapter.c
index b18fbb137c..862c540b6c 100644
--- a/widgets/table/e-tree-table-adapter.c
+++ b/widgets/table/e-tree-table-adapter.c
@@ -265,13 +265,14 @@ find_row_num(ETreeTableAdapter *etta, ETreePath path)
if (etta->priv->last_access != -1) {
int end = MIN(etta->priv->n_map, etta->priv->last_access + 10);
int start = MAX(0, etta->priv->last_access - 10);
- for (i = etta->priv->last_access; i < end; i++) {
+ int initial = MAX (MIN (etta->priv->last_access, end), start);
+ for (i = initial; i < end; i++) {
if(etta->priv->map_table[i] == path) {
d(g_print("Found last access %d at row %d. (find_row_num)\n", etta->priv->last_access, i));
return i;
}
}
- for (i = etta->priv->last_access - 1; i >= start; i--) {
+ for (i = initial - 1; i >= start; i--) {
if(etta->priv->map_table[i] == path) {
d(g_print("Found last access %d at row %d. (find_row_num)\n", etta->priv->last_access, i));
return i;