Solution 2:
The patch below fixes the time complexity, and so far as I can see
introduces no adverse effects. However I haven't done any very
thorough testing.
It removes a loop which calls _pspp_sheet_view_column_cell_set_dirty
on all the columns. Note that the function _pspp_sheet_view_column_cell_set_dirty
sets a flag:
tree_column->dirty = TRUE;
but there is nothing in our code which reads this flag or unsets it.
Perhaps it is here only for historical reasons?
From 54d20e902513f7a890c727cc45d31dceb64679ed Mon Sep 17 00:00:00 2001
From: John Darrington <
address@hidden>
Date: Wed, 24 Feb 2016 09:21:36 +0100
Subject: [PATCH] pspp-sheet-view.c: Remove inner loop from column insertion
and removal operations
This appears to do no harm and moves the complexity from O(n^2) to O(n).
From 54d20e902513f7a890c727cc45d31dceb64679ed Mon Sep 17 00:00:00 2001
From: John Darrington <
address@hidden>
Date: Wed, 24 Feb 2016 09:21:36 +0100
Subject: [PATCH] pspp-sheet-view.c: Remove inner loop from column insertion
and removal operations
This appears to do no harm and moves the complexity from O(n^2) to O(n).
---
src/ui/gui/pspp-sheet-view.c | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/src/ui/gui/pspp-sheet-view.c b/src/ui/gui/pspp-sheet-view.c
index fe70504..7ff7569 100644
--- a/src/ui/gui/pspp-sheet-view.c
+++ b/src/ui/gui/pspp-sheet-view.c
@@ -8927,14 +8927,6 @@ pspp_sheet_view_remove_column (PsppSheetView *tree_view,
GList *list;
_pspp_sheet_view_column_unrealize_button (column);
- for (list = tree_view->priv->columns; list; list = list->next)
-
{
-
PsppSheetViewColumn *tmp_column;
-
-
tmp_column = PSPP_SHEET_VIEW_COLUMN (list->data);
-
if (tmp_column->visible)
-
_pspp_sheet_view_column_cell_set_dirty (tmp_column);
-
}
if (tree_view->priv->n_columns == 0 &&
pspp_sheet_view_get_headers_visible (tree_view) &&
@@ -8991,12 +8983,6 @@ pspp_sheet_view_insert_column (PsppSheetView *tree_view,
_pspp_sheet_view_column_realize_button (column);
- for (list = tree_view->priv->columns; list; list = list->next)
-
{
-
column = PSPP_SHEET_VIEW_COLUMN (list->data);
-
if (column->visible)
-
_pspp_sheet_view_column_cell_set_dirty (column);
-
}
gtk_widget_queue_resize (GTK_WIDGET (tree_view));
}
--
2.1.4