sc/source/core/data/column2.cxx      |    1 
 sc/source/core/data/formulacell.cxx  |    5 ----
 sc/source/core/tool/formulagroup.cxx |   37 +++++++++++++++++++++++++----------
 3 files changed, 28 insertions(+), 15 deletions(-)

New commits:
commit 15cf5afea05f0539035a1393b3150121489eb561
Author: Kohei Yoshida <kohei.yosh...@gmail.com>
Date:   Fri Jul 12 15:11:19 2013 -0400

    Don't forget to shift to the right start element within the block!
    
    Else it would always start from element one of the block regardless of
    the requested start row position.
    
    Change-Id: I3843eab2a88b8361250346e3f9696be5086039ea

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 7b38918..8695581 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2244,6 +2244,7 @@ const double* ScColumn::FetchDoubleArray( 
sc::FormulaGroupContext& rCxt, SCROW n
             rArray.reserve(nLenRequested);
 
             sc::formula_block::const_iterator it = 
sc::formula_block::begin(*aPos.first->data);
+            std::advance(it, aPos.second);
             sc::formula_block::const_iterator itEnd;
             if (nLenRequested <= nLen)
             {
commit 2e614e9d01a5e00506b14ecf0588e01d4d5716e3
Author: Kohei Yoshida <kohei.yosh...@gmail.com>
Date:   Fri Jul 12 15:11:04 2013 -0400

    This comment is no longer correct.
    
    Change-Id: I815016551ea979d27e1f402dc2badda0d856a229

diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 55f5010..570b55c 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -3093,11 +3093,6 @@ public:
                         // returned array equals or greater than the requested
                         // length.
 
-                        // TODO: For now, it returns an array pointer only when
-                        // the entire array is in contiguous memory space.  
Once
-                        // we finish cell storage rework, we'll support 
temporary
-                        // generation of a double array which is a combination 
of
-                        // multiple cell array segments.
                         const double* pArray = mrDoc.FetchDoubleArray(mrCxt, 
aRefPos, mrCell.GetCellGroup()->mnLength);
                         if (!pArray)
                             return false;
commit cffba76a3487628f0557b423cefe150932308ede
Author: Kohei Yoshida <kohei.yosh...@gmail.com>
Date:   Fri Jul 12 11:40:54 2013 -0400

    Cache select converted tokens to avoid unnecessary token duplication.
    
    Change-Id: I3a63d5cbbc1cdc37d681ffd41ec22ff65e56cc0d

diff --git a/sc/source/core/tool/formulagroup.cxx 
b/sc/source/core/tool/formulagroup.cxx
index 6573d15..4ac4b6b 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -19,6 +19,7 @@
 #include "formula/vectortoken.hxx"
 
 #include <vector>
+#include <boost/unordered_map.hpp>
 
 #define USE_DUMMY_INTERPRETER 1
 
@@ -37,6 +38,8 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& 
rDoc, const ScAddres
                                                 const ScFormulaCellGroupRef& 
xGroup,
                                                 ScTokenArray& rCode)
 {
+    typedef boost::unordered_map<const formula::FormulaToken*, 
formula::FormulaTokenRef> CachedTokensType;
+
     // Decompose the group into individual cells and calculate them 
individually.
 
     // The caller must ensure that the top position is the start position of
@@ -45,11 +48,21 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& 
rDoc, const ScAddres
     ScAddress aTmpPos = rTopPos;
     std::vector<double> aResults;
     aResults.reserve(xGroup->mnLength);
+    CachedTokensType aCachedTokens;
+
     for (SCROW i = 0; i < xGroup->mnLength; ++i, aTmpPos.IncRow())
     {
         ScTokenArray aCode2;
         for (const formula::FormulaToken* p = rCode.First(); p; p = 
rCode.Next())
         {
+            CachedTokensType::iterator it = aCachedTokens.find(p);
+            if (it != aCachedTokens.end())
+            {
+                // This token is cached. Use the cached one.
+                aCode2.AddToken(*it->second);
+                continue;
+            }
+
             switch (p->GetType())
             {
                 case formula::svSingleVectorRef:
@@ -77,8 +90,18 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& 
rDoc, const ScAddres
                         pMat->PutDouble(pArray, nRowSize, nCol, 0);
                     }
 
-                    ScMatrixToken aTok(pMat);
-                    aCode2.AddToken(aTok);
+                    if (p2->IsStartFixed() && p2->IsEndFixed())
+                    {
+                        // Cached the converted token for absolute range 
referene.
+                        formula::FormulaTokenRef xTok(new ScMatrixToken(pMat));
+                        aCachedTokens.insert(CachedTokensType::value_type(p, 
xTok));
+                        aCode2.AddToken(*xTok);
+                    }
+                    else
+                    {
+                        ScMatrixToken aTok(pMat);
+                        aCode2.AddToken(aTok);
+                    }
                 }
                 break;
                 default:
commit 1a74c58bea4619de03bec6fa1fe00b51dd8e7d73
Author: Kohei Yoshida <kohei.yosh...@gmail.com>
Date:   Fri Jul 12 11:09:38 2013 -0400

    Set an array of doubles in one step, rather than individually in loops.
    
    The latter is massively slow, apparently.
    
    Change-Id: I689643330e1b04eff7d9665de5d6e423906517e1

diff --git a/sc/source/core/tool/formulagroup.cxx 
b/sc/source/core/tool/formulagroup.cxx
index 5a23511..6573d15 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -73,14 +73,8 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& 
rDoc, const ScAddres
                     for (size_t nCol = 0; nCol < nColSize; ++nCol)
                     {
                         const double* pArray = rArrays[nCol];
-                        for (size_t nRow = 0; nRow < nRowSize; ++nRow)
-                        {
-                            if (nRowStart + nRow < p2->GetArrayLength())
-                            {
-                                double fVal = pArray[nRowStart+nRow];
-                                pMat->PutDouble(fVal, nCol, nRow);
-                            }
-                        }
+                        pArray += nRowStart;
+                        pMat->PutDouble(pArray, nRowSize, nCol, 0);
                     }
 
                     ScMatrixToken aTok(pMat);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to