[gnumeric] Conditional formats: speedup.



commit 304bbfa8d1ce3f7e6b7cbafc82df6523314dffb6
Author: Morten Welinder <terra gnome org>
Date:   Tue May 20 13:13:15 2014 -0400

    Conditional formats: speedup.
    
    We don't need to link certain harmless expressions used in conditional
    formats.  That includes the common case of constants.

 ChangeLog    |    5 +++++
 NEWS         |    1 +
 src/mstyle.c |   24 +++++++++++++++++++++++-
 3 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 738b4b0..4031be7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-05-20  Morten Welinder  <terra gnome org>
+
+       * src/mstyle.c (gnm_style_link_dependents): Speed up certain large
+       conditional format ranges.
+
 2014-05-14  Morten Welinder  <terra gnome org>
 
        * src/ssindex.c (ssindex): Use gnm_object_has_readable_prop.
diff --git a/NEWS b/NEWS
index c65091a..f28aede 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ Morten:
        * Fix plan-perfect issue.  [Debian #748054]
        * Make installtion work without scrollkeeper.
        * Improve import/export testing.  [#730397]
+       * Speed up certain large ranges of conditional formatting.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.15
diff --git a/src/mstyle.c b/src/mstyle.c
index 9c3c5e9..dec5b00 100644
--- a/src/mstyle.c
+++ b/src/mstyle.c
@@ -18,6 +18,7 @@
 #include "application.h"
 #include "parse-util.h"
 #include "expr.h"
+#include "value.h"
 #include "gutils.h"
 #include "ranges.h"
 #include "gnumeric-conf.h"
@@ -1884,6 +1885,26 @@ debug_style_deps (void)
        return debug;
 }
 
+/*
+ * Just a simple version for now.  We can also ignore most function
+ * calls[1] and self-references[2].
+ *
+ * [1] Excluding volatile (TODAY, ...) and those that can create references
+ * outside the arguments (INDIRECT).
+ *
+ * [2] References that print like A1 when used in A1.
+ */
+static gboolean
+cond_expr_harmless (GnmExpr const *expr)
+{
+       GnmValue const *v = gnm_expr_get_constant (expr);
+       if (v && v->type != VALUE_CELLRANGE)
+               return TRUE;
+
+       return FALSE;
+}
+
+
 void
 gnm_style_link_dependents (GnmStyle *style, GnmRange const *r)
 {
@@ -1917,7 +1938,8 @@ gnm_style_link_dependents (GnmStyle *style, GnmRange const *r)
                        for (ei = 0; ei < 2; ei++) {
                                GnmExprTop const *texpr =
                                        gnm_style_cond_get_expr (c, ei);
-                               if (!texpr)
+                               if (!texpr ||
+                                   cond_expr_harmless (texpr->expr))
                                        continue;
                                if (!style->deps)
                                        style->deps = g_ptr_array_new ();


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