[Libreoffice-commits] core.git: sc/source

Eike Rathke erack at redhat.com
Thu Jun 1 16:02:41 UTC 2017


 sc/source/core/tool/interpr6.cxx |   34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

New commits:
commit e4f2aab11721cc6842c2c821ff9dacebc6095a56
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jun 1 17:58:58 2017 +0200

    Perf: do not calculate a null-operation with the result matrix, tdf#58874
    
    i.e. with an empty set within an svRefList when advancing to the next reference.
    
    Change-Id: Iae81c3a0cd3c30ab113ad74881a0f28b78b0973d

diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 0db0bd226373..cff34f262ad8 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -506,7 +506,11 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero )
     short nParamCount = GetByte();
     const SCSIZE nMatRows = GetRefListArrayMaxSize( nParamCount);
     ScMatrixRef xResMat, xResCount;
-    double fRes = ( eFunc == ifPRODUCT ) ? 1.0 : 0.0;
+    auto ResInitVal = [eFunc]()
+    {
+        return (eFunc == ifPRODUCT) ? 1.0 : 0.0;
+    };
+    double fRes = ResInitVal();
     double fVal = 0.0;
     double fMem = 0.0;  // first numeric value != 0.0
     sal_uLong nCount = 0;
@@ -753,19 +757,27 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero )
                     {
                         // Current value and values from vector are operands
                         // for each vector position.
-                        for (SCSIZE i=0; i < nMatRows; ++i)
+                        if (nCount && xResCount)
                         {
-                            if (xResCount)
+                            for (SCSIZE i=0; i < nMatRows; ++i)
+                            {
                                 xResCount->PutDouble( xResCount->GetDouble(0,i) + nCount, 0,i);
-                            double fVecRes = xResMat->GetDouble(0,i);
-                            if (eFunc == ifPRODUCT)
-                                fVecRes *= fRes;
-                            else
-                                fVecRes += fRes;
-                            xResMat->PutDouble( fVecRes, 0,i);
+                            }
+                        }
+                        if (fRes != ResInitVal())
+                        {
+                            for (SCSIZE i=0; i < nMatRows; ++i)
+                            {
+                                double fVecRes = xResMat->GetDouble(0,i);
+                                if (eFunc == ifPRODUCT)
+                                    fVecRes *= fRes;
+                                else
+                                    fVecRes += fRes;
+                                xResMat->PutDouble( fVecRes, 0,i);
+                            }
                         }
                     }
-                    fRes = ((eFunc == ifPRODUCT) ? 1.0 : 0.0);
+                    fRes = ResInitVal();
                     nCount = 0;
                 }
             }
@@ -943,7 +955,7 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero )
                         fVecRes += fRes;
                     xResMat->PutDouble( fVecRes, 0,nRefArrayPos);
                     // Reset.
-                    fRes = ((eFunc == ifPRODUCT) ? 1.0 : 0.0);
+                    fRes = ResInitVal();
                     nCount = 0;
                     nRefArrayPos = std::numeric_limits<size_t>::max();
                 }


More information about the Libreoffice-commits mailing list