[Libreoffice-commits] core.git: Branch 'private/kohei/xlsx-import-speedup' - 2 commits - sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Fri Nov 8 20:35:36 CET 2013


 sc/source/core/data/column.cxx         |    2 +-
 sc/source/filter/oox/formulabuffer.cxx |   24 +++++++++++++++---------
 2 files changed, 16 insertions(+), 10 deletions(-)

New commits:
commit b946a933214406fe263f580dc190d41bc334a543
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Nov 8 14:36:40 2013 -0500

    This is clearly a mistake.
    
    Change-Id: Id87e120d80b823db9be989db7a7b2ac383304f77

diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 12fc80a..0b7f0c3 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1284,7 +1284,7 @@ class CopyToClipHandler
         for (++it; it != itEnd; ++it, pPrev = pCur)
         {
             pCur = *it;
-            ScFormulaCell::CompareState eState = pPrev->CompareByTokenArray(*pPrev);
+            ScFormulaCell::CompareState eState = pPrev->CompareByTokenArray(*pCur);
             if (eState == ScFormulaCell::NotEqual)
                 continue;
 
commit 3c9a00f0c86155056b4a8155aa5f30e2a4403967
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Nov 8 14:30:03 2013 -0500

    Store the formula cell instance in cache rather than the token array.
    
    Change-Id: I1c4a0897c46458d6ee086e7f72ab8a03aa54c9e0

diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index d9c164a..eb1892b 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -51,10 +51,11 @@ public:
     struct Item : boost::noncopyable
     {
         SCROW mnRow;
-        boost::scoped_ptr<ScTokenArray> mpCode;
+        ScFormulaCell* mpCell;
 
-        Item() : mnRow(-1), mpCode(NULL) {}
-        Item( SCROW nRow, ScTokenArray* p ) : mnRow(nRow), mpCode(p) {}
+        Item() : mnRow(-1), mpCell(NULL) {}
+        Item( SCROW nRow, ScFormulaCell* pCell ) :
+            mnRow(nRow), mpCell(pCell) {}
     };
 
     CachedTokenArray( ScDocument& rDoc ) : mrDoc(rDoc) {}
@@ -74,7 +75,7 @@ public:
             return NULL;
 
         Item& rCached = *it->second;
-        ScCompiler aComp(&mrDoc, rPos, *rCached.mpCode);
+        ScCompiler aComp(&mrDoc, rPos, *rCached.mpCell->GetCode());
         aComp.SetGrammar(formula::FormulaGrammar::GRAM_ENGLISH_XL_OOX);
         OUStringBuffer aBuf;
         aComp.CreateStringFromTokenArray(aBuf);
@@ -85,7 +86,7 @@ public:
         return NULL;
     }
 
-    void store( const ScAddress& rPos, const ScTokenArray& rArray )
+    void store( const ScAddress& rPos, ScFormulaCell* pCell )
     {
         ColCacheType::iterator it = maCache.find(rPos.Col());
         if (it == maCache.end())
@@ -100,8 +101,9 @@ public:
             it = r.first;
         }
 
-        it->second->mnRow = rPos.Row();
-        it->second->mpCode.reset(rArray.Clone());
+        Item& rItem = *it->second;
+        rItem.mnRow = rPos.Row();
+        rItem.mpCell = pCell;
     }
 
 private:
@@ -187,8 +189,12 @@ void applyCellFormulas(
         if (p)
         {
             // Use the cached version to avoid re-compilation.
-            ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, p->mpCode->Clone());
+            ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, p->mpCell->GetCode()->Clone());
             rDoc.setFormulaCell(aPos, pCell);
+
+            // Update the cache.
+            p->mnRow = aPos.Row();
+            p->mpCell = pCell;
             continue;
         }
 
@@ -201,7 +207,7 @@ void applyCellFormulas(
 
         ScFormulaCell* pCell = new ScFormulaCell(&rDoc.getDoc(), aPos, pCode);
         rDoc.setFormulaCell(aPos, pCell);
-        rCache.store(aPos, *pCode);
+        rCache.store(aPos, pCell);
     }
 }
 


More information about the Libreoffice-commits mailing list