[gnumeric] xls export: fix performance problem.



commit 0706c60dd3438cb104c6212ee9ce87983bfd3ce3
Author: Morten Welinder <terra gnome org>
Date:   Tue May 5 15:51:17 2009 -0400

    xls export: fix performance problem.
---
 NEWS                           |    1 +
 plugins/excel/ChangeLog        |    5 +++++
 plugins/excel/ms-excel-write.c |   17 ++++++++++++++++-
 3 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index 5916cd0..992da0c 100644
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,7 @@ Morten:
 	* Fix long-sheet-name GUI issue.  [#580837]
 	* Fix dependency problem with names.  [#581117]
 	* Fix style-allocation screwup.
+	* Fix xls export performance problem.  [#581378]
 
 --------------------------------------------------------------------------
 Gnumeric 1.9.6
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 03dedf8..2c407a7 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2009-05-05  Morten Welinder  <terra gnome org>
+
+	* ms-excel-write.c (excel_sheet_write_block): Add one-element
+	cache.  Fixes #581378.
+
 2009-05-02  Jean Brefort  <jean brefort normalesup org>
 
 	* ms-chart.c (get_style), (ms_excel_chart_read): use reimplemented
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index 0a1850f..d7866b0 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -4695,6 +4695,8 @@ excel_sheet_write_block (ExcelWriteSheet *esheet, guint32 begin, int nrows,
 	Sheet		*sheet = esheet->gnum_sheet;
 	TwoWayTable *twt = esheet->ewb->base.xf.two_way_table;
 	gboolean has_content = FALSE;
+	ExcelStyleVariant esv_cache;
+	int esv_cache_xf;
 
 	xf_list = g_new (gint16, gnm_sheet_get_max_cols (esheet->gnum_sheet));
 	if (nrows > esheet->max_row - (int) begin) /* Incomplete final block? */
@@ -4706,6 +4708,11 @@ excel_sheet_write_block (ExcelWriteSheet *esheet, guint32 begin, int nrows,
 	for (row = begin + 1; row <= max_row; row++)
 		(void) excel_write_ROWINFO (ewb->bp, esheet, row, max_col);
 
+	/* One-element cache for efficiency.  Checked with eq only.  #581378 */
+	esv_cache_xf = -1;
+	esv_cache.variant = 42;
+	esv_cache.style = NULL;
+
 	r.start.col = 0;
 	r.end.col = max_col-1;
 
@@ -4733,7 +4740,15 @@ excel_sheet_write_block (ExcelWriteSheet *esheet, guint32 begin, int nrows,
 				(ewb->base.xf.value_fmt_styles, cell);
 			if (esv.style == NULL)
 				esv.style = sheet_style_get (sheet, col, row);
-			xf = two_way_table_key_to_idx (twt, &esv);
+
+			if (esv.variant == esv_cache.variant &&
+			    esv.style == esv_cache.style)
+				xf = esv_cache_xf;
+			else {
+				esv_cache = esv;
+				esv_cache_xf = xf =
+					two_way_table_key_to_idx (twt, &esv);
+			}
 
 			if (xf < 0) {
 				g_warning ("Can't find style %p for cell %s!%s",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]