From e76ecc31c5922b4a89ebcac0a48c11c9d6fe0fa7 Mon Sep 17 00:00:00 2001 From: Rusty Conover Date: Sat, 17 Feb 2001 07:29:22 +0000 Subject: Change the calculation of the maximum with of tree cell, from O(n^2) to 2001-02-17 Rusty Conover * e-cell-tree.c (ect_max_width): Change the calculation of the maximum with of tree cell, from O(n^2) to O(n), we don't need to continually recalculate the maximum width of the subcells when calculating the width of every row. svn path=/trunk/; revision=8264 --- widgets/table/e-cell-tree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'widgets/table') diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c index 97c6215056..f056cde271 100644 --- a/widgets/table/e-cell-tree.c +++ b/widgets/table/e-cell-tree.c @@ -386,8 +386,11 @@ ect_max_width (ECellView *ecell_view, int model_col, int view_col) int number_of_rows; int max_width = 0; int width = 0; + int subcell_max_width; number_of_rows = e_table_model_row_count (ecell_view->e_table_model); + + subcell_max_width = e_cell_max_width (tree_view->subcell_view, model_col, view_col); for (row = 0; row < number_of_rows; row++) { ETreeModel *tree_model = e_cell_tree_get_tree_model(ecell_view->e_table_model, row); @@ -412,7 +415,7 @@ ect_max_width (ECellView *ecell_view, int model_col, int view_col) node_image_height = gdk_pixbuf_get_height (node_image); } - width = subcell_offset + node_image_width; + width = subcell_max_width + subcell_offset + node_image_width; if (expandable) { GdkPixbuf *image; @@ -424,9 +427,6 @@ ect_max_width (ECellView *ecell_view, int model_col, int view_col) width += gdk_pixbuf_get_width(image); } - width += e_cell_max_width (tree_view->subcell_view, model_col, - view_col); - max_width = MAX (max_width, width); } -- cgit v1.2.3