[gnumeric] Stf import: auto-size columns only based on 1000 rows.



commit 45ef1eea41fcbd5c434195d6f344a7617620acf7
Author: Morten Welinder <terra gnome org>
Date:   Sat Oct 27 16:13:51 2012 -0400

    Stf import: auto-size columns only based on 1000 rows.
    
    Auto-fitting potentially millions of cells takes a while.  Using the first
    1000 rows is likely to get roughly the same result, but much faster.

 ChangeLog |    5 +++++
 NEWS      |    1 +
 src/stf.c |    6 ++++++
 3 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3abf9cb..c2a01af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-10-27  Morten Welinder  <terra gnome org>
+
+	* src/stf.c (resize_columns): Only auto-resize columns based on
+	the first 1000 rows.  Fixes #686858.
+
 2012-10-26  Morten Welinder  <terra gnome org>
 
 	* src/gutils.c (gnm_utf8_strto): Handle all-ascii case without
diff --git a/NEWS b/NEWS
index 9dbb854..7649a89 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ Morten:
 	* Fix xlsx save performance problems.  [#662058]  [#685530]
 	* Fix ods save performance problems.  [#662057]
 	* Make .gnumeric use fewer style rectangles for the same style.
+	* Short-circuit column resize for large stf imports.  [#686858]
 
 Weng Xuetian:
         * Fix interaction with ibus & fcitx. [#684511]
diff --git a/src/stf.c b/src/stf.c
index 400d896..1065697 100644
--- a/src/stf.c
+++ b/src/stf.c
@@ -190,7 +190,13 @@ resize_columns (Sheet *sheet)
 
 	if (gnm_debug_flag ("stf"))
 		g_printerr ("Auto-fitting columns...\n");
+
+	/* If we have lots of rows, auto-fitting will take a very long
+	   time.  It is probably better to look at only, say, 1000 rows
+	   of data.  */
 	range_init_full_sheet (&r, sheet);
+	r.end.row = MIN (r.end.row, 1000);
+
 	colrow_autofit (sheet, &r, TRUE,
 			TRUE, /* Ignore strings */
 			TRUE, /* Don't shrink */



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