[Libreoffice-commits] core.git: Branch 'feature/fixes10' - sc/inc sc/source

Tor Lillqvist tml at collabora.com
Fri Oct 2 07:06:18 PDT 2015


 sc/inc/columnspanset.hxx                  |   56 ++++++++++++++++++++++++------
 sc/source/core/data/columnspanset.cxx     |   45 ------------------------
 sc/source/core/data/document.cxx          |    6 +--
 sc/source/core/data/table3.cxx            |   12 +++---
 sc/source/core/tool/grouparealistener.cxx |    6 +--
 sc/source/core/tool/interpr6.cxx          |   12 +++---
 sc/source/ui/docshell/externalrefmgr.cxx  |    6 +--
 sc/source/ui/undo/undobase.cxx            |    6 +--
 8 files changed, 70 insertions(+), 79 deletions(-)

New commits:
commit 4af1f150cd39f325bb2e86337e6389c36084a6ba
Author: Tor Lillqvist <tml at collabora.com>
Date:   Fri Oct 2 17:04:54 2015 +0300

    Replace derivation from ColumnAction with template
    
    Will see if it gives a performance improvement.
    
    Change-Id: Ib45c2879cf3e974e05c83e2323be57557da58ffd

diff --git a/sc/inc/columnspanset.hxx b/sc/inc/columnspanset.hxx
index 797b425..7e5123c 100644
--- a/sc/inc/columnspanset.hxx
+++ b/sc/inc/columnspanset.hxx
@@ -11,12 +11,13 @@
 #define INCLUDED_SC_INC_COLUMNSPANSET_HXX
 
 #include "address.hxx"
+#include "document.hxx"
+#include "table.hxx"
 
 #include <vector>
 #include <mdds/flat_segment_tree.hpp>
 #include <boost/noncopyable.hpp>
 
-class ScDocument;
 class ScColumn;
 class ScMarkData;
 class ScRange;
@@ -78,14 +79,6 @@ public:
         virtual void execute(const ScAddress& rPos, SCROW nLength, bool bVal) = 0;
     };
 
-    class ColumnAction
-    {
-    public:
-        virtual ~ColumnAction() = 0;
-        virtual void startColumn(ScColumn* pCol) = 0;
-        virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal) = 0;
-    };
-
     ColumnSpanSet(bool bInit);
     ~ColumnSpanSet();
 
@@ -102,7 +95,50 @@ public:
     void scan(const ScDocument& rDoc, SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bVal);
 
     void executeAction(Action& ac) const;
-    void executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const;
+
+    template<typename ColumnAction>
+    void executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const
+    {
+        for (size_t nTab = 0; nTab < maDoc.size(); ++nTab)
+        {
+            if (!maDoc[nTab])
+                continue;
+
+            const TableType& rTab = *maDoc[nTab];
+            for (size_t nCol = 0; nCol < rTab.size(); ++nCol)
+            {
+                if (!rTab[nCol])
+                    continue;
+
+                ScTable* pTab = rDoc.FetchTable(nTab);
+                if (!pTab)
+                    continue;
+
+                if (!ValidCol(nCol))
+                {
+                    // End the loop.
+                    nCol = rTab.size();
+                    continue;
+                }
+
+                ScColumn& rColumn = pTab->aCol[nCol];
+                ac.startColumn(&rColumn);
+                ColumnType& rCol = *rTab[nCol];
+                ColumnSpansType::const_iterator it = rCol.maSpans.begin(), itEnd = rCol.maSpans.end();
+                SCROW nRow1, nRow2;
+                nRow1 = it->first;
+                bool bVal = it->second;
+                for (++it; it != itEnd; ++it)
+                {
+                    nRow2 = it->first-1;
+                    ac.execute(nRow1, nRow2, bVal);
+
+                    nRow1 = nRow2+1; // for the next iteration.
+                    bVal = it->second;
+                }
+            }
+        }
+    }
 
     void swap( ColumnSpanSet& r );
 };
diff --git a/sc/source/core/data/columnspanset.cxx b/sc/source/core/data/columnspanset.cxx
index 25f6b5b..a444c54 100644
--- a/sc/source/core/data/columnspanset.cxx
+++ b/sc/source/core/data/columnspanset.cxx
@@ -54,8 +54,6 @@ ColumnSpanSet::ColumnType::ColumnType(SCROW nStart, SCROW nEnd, bool bInit) :
 ColumnSpanSet::Action::~Action() {}
 void ColumnSpanSet::Action::startColumn(SCTAB /*nTab*/, SCCOL /*nCol*/) {}
 
-ColumnSpanSet::ColumnAction::~ColumnAction() {}
-
 ColumnSpanSet::ColumnSpanSet(bool bInit) : mbInit(bInit) {}
 
 ColumnSpanSet::~ColumnSpanSet()
@@ -184,49 +182,6 @@ void ColumnSpanSet::executeAction(Action& ac) const
     }
 }
 
-void ColumnSpanSet::executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const
-{
-    for (size_t nTab = 0; nTab < maDoc.size(); ++nTab)
-    {
-        if (!maDoc[nTab])
-            continue;
-
-        const TableType& rTab = *maDoc[nTab];
-        for (size_t nCol = 0; nCol < rTab.size(); ++nCol)
-        {
-            if (!rTab[nCol])
-                continue;
-
-            ScTable* pTab = rDoc.FetchTable(nTab);
-            if (!pTab)
-                continue;
-
-            if (!ValidCol(nCol))
-            {
-                // End the loop.
-                nCol = rTab.size();
-                continue;
-            }
-
-            ScColumn& rColumn = pTab->aCol[nCol];
-            ac.startColumn(&rColumn);
-            ColumnType& rCol = *rTab[nCol];
-            ColumnSpansType::const_iterator it = rCol.maSpans.begin(), itEnd = rCol.maSpans.end();
-            SCROW nRow1, nRow2;
-            nRow1 = it->first;
-            bool bVal = it->second;
-            for (++it; it != itEnd; ++it)
-            {
-                nRow2 = it->first-1;
-                ac.execute(nRow1, nRow2, bVal);
-
-                nRow1 = nRow2+1; // for the next iteration.
-                bVal = it->second;
-            }
-        }
-    }
-}
-
 void ColumnSpanSet::swap( ColumnSpanSet& r )
 {
     maDoc.swap(r.maDoc);
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 153b77f..ddb8f3d 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2644,7 +2644,7 @@ void ScDocument::CopyNonFilteredFromClip(
 
 namespace {
 
-class BroadcastAction : public sc::ColumnSpanSet::ColumnAction
+class BroadcastAction
 {
     ScDocument& mrDoc;
     ScColumn* mpCol;
@@ -2652,12 +2652,12 @@ class BroadcastAction : public sc::ColumnSpanSet::ColumnAction
 public:
     BroadcastAction( ScDocument& rDoc ) : mrDoc(rDoc), mpCol(NULL) {}
 
-    virtual void startColumn( ScColumn* pCol ) SAL_OVERRIDE
+    void startColumn( ScColumn* pCol )
     {
         mpCol = pCol;
     }
 
-    virtual void execute( SCROW nRow1, SCROW nRow2, bool bVal ) SAL_OVERRIDE
+    void execute( SCROW nRow1, SCROW nRow2, bool bVal )
     {
         if (!bVal)
             return;
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 1c5a551..99c01fe 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -844,7 +844,7 @@ void expandRowRange( ScRange& rRange, SCROW nTop, SCROW nBottom )
         rRange.aEnd.SetRow(nBottom);
 }
 
-class FormulaCellCollectAction : public sc::ColumnSpanSet::ColumnAction
+class FormulaCellCollectAction
 {
     std::vector<ScFormulaCell*>& mrCells;
     ScColumn* mpCol;
@@ -853,12 +853,12 @@ public:
     FormulaCellCollectAction( std::vector<ScFormulaCell*>& rCells ) :
         mrCells(rCells), mpCol(NULL) {}
 
-    virtual void startColumn( ScColumn* pCol ) SAL_OVERRIDE
+    void startColumn( ScColumn* pCol )
     {
         mpCol = pCol;
     }
 
-    virtual void execute( SCROW nRow1, SCROW nRow2, bool bVal ) SAL_OVERRIDE
+    void execute( SCROW nRow1, SCROW nRow2, bool bVal )
     {
         assert(mpCol);
 
@@ -869,7 +869,7 @@ public:
     }
 };
 
-class ListenerStartAction : public sc::ColumnSpanSet::ColumnAction
+class ListenerStartAction
 {
     ScColumn* mpCol;
 
@@ -884,12 +884,12 @@ public:
         maStartCxt(rDoc, mpPosSet),
         maEndCxt(rDoc, mpPosSet) {}
 
-    virtual void startColumn( ScColumn* pCol ) SAL_OVERRIDE
+    void startColumn( ScColumn* pCol )
     {
         mpCol = pCol;
     }
 
-    virtual void execute( SCROW nRow1, SCROW nRow2, bool bVal ) SAL_OVERRIDE
+    void execute( SCROW nRow1, SCROW nRow2, bool bVal )
     {
         assert(mpCol);
 
diff --git a/sc/source/core/tool/grouparealistener.cxx b/sc/source/core/tool/grouparealistener.cxx
index ac9ea7f..50f64806 100644
--- a/sc/source/core/tool/grouparealistener.cxx
+++ b/sc/source/core/tool/grouparealistener.cxx
@@ -34,7 +34,7 @@ public:
     }
 };
 
-class CollectCellAction : public sc::ColumnSpanSet::ColumnAction
+class CollectCellAction
 {
     const FormulaGroupAreaListener& mrAreaListener;
     ScAddress maPos;
@@ -44,13 +44,13 @@ public:
     CollectCellAction( const FormulaGroupAreaListener& rAreaListener ) :
         mrAreaListener(rAreaListener) {}
 
-    virtual void startColumn( ScColumn* pCol ) SAL_OVERRIDE
+    void startColumn( ScColumn* pCol )
     {
         maPos.SetTab(pCol->GetTab());
         maPos.SetCol(pCol->GetCol());
     }
 
-    virtual void execute( SCROW nRow1, SCROW nRow2, bool bVal ) SAL_OVERRIDE
+    void execute( SCROW nRow1, SCROW nRow2, bool bVal )
     {
         if (!bVal)
             return;
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index b3daedd..250f71d 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -278,7 +278,7 @@ public:
     size_t getCount() const { return mnCount; }
 };
 
-class FuncCount : public sc::ColumnSpanSet::ColumnAction
+class FuncCount
 {
     sc::ColumnBlockConstPosition maPos;
     ScColumn* mpCol;
@@ -288,13 +288,13 @@ class FuncCount : public sc::ColumnSpanSet::ColumnAction
 public:
     FuncCount() : mpCol(0), mnCount(0), mnNumFmt(0) {}
 
-    virtual void startColumn(ScColumn* pCol) SAL_OVERRIDE
+    void startColumn(ScColumn* pCol)
     {
         mpCol = pCol;
         mpCol->InitBlockPosition(maPos);
     }
 
-    virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal) SAL_OVERRIDE
+    void execute(SCROW nRow1, SCROW nRow2, bool bVal)
     {
         if (!bVal)
             return;
@@ -309,7 +309,7 @@ public:
     sal_uInt32 getNumberFormat() const { return mnNumFmt; }
 };
 
-class FuncSum : public sc::ColumnSpanSet::ColumnAction
+class FuncSum
 {
     sc::ColumnBlockConstPosition maPos;
     ScColumn* mpCol;
@@ -320,13 +320,13 @@ class FuncSum : public sc::ColumnSpanSet::ColumnAction
 public:
     FuncSum() : mpCol(0), mfSum(0.0), mnError(0), mnNumFmt(0) {}
 
-    virtual void startColumn(ScColumn* pCol) SAL_OVERRIDE
+    void startColumn(ScColumn* pCol)
     {
         mpCol = pCol;
         mpCol->InitBlockPosition(maPos);
     }
 
-    virtual void execute(SCROW nRow1, SCROW nRow2, bool bVal) SAL_OVERRIDE
+    void execute(SCROW nRow1, SCROW nRow2, bool bVal)
     {
         if (!bVal)
             return;
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 36a3882..fdd911f 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2669,7 +2669,7 @@ void ScExternalRefManager::clearCache(sal_uInt16 nFileId)
 
 namespace {
 
-class RefCacheFiller : public sc::ColumnSpanSet::ColumnAction
+class RefCacheFiller
 {
     svl::SharedStringPool& mrStrPool;
 
@@ -2683,7 +2683,7 @@ public:
     RefCacheFiller( svl::SharedStringPool& rStrPool, ScExternalRefCache& rRefCache, sal_uInt16 nFileId ) :
         mrStrPool(rStrPool), mrRefCache(rRefCache), mnFileId(nFileId), mpCurCol(NULL) {}
 
-    virtual void startColumn( ScColumn* pCol ) SAL_OVERRIDE
+    void startColumn( ScColumn* pCol )
     {
         mpCurCol = pCol;
         if (!mpCurCol)
@@ -2693,7 +2693,7 @@ public:
         mpRefTab = mrRefCache.getCacheTable(mnFileId, mpCurCol->GetTab());
     }
 
-    virtual void execute( SCROW nRow1, SCROW nRow2, bool bVal ) SAL_OVERRIDE
+    void execute( SCROW nRow1, SCROW nRow2, bool bVal )
     {
         if (!mpCurCol || !bVal)
             return;
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index a383eed..0af2b33 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -152,7 +152,7 @@ void ScSimpleUndo::BroadcastChanges( const ScRange& rRange )
 
 namespace {
 
-class SpanBroadcaster : public sc::ColumnSpanSet::ColumnAction
+class SpanBroadcaster
 {
     ScDocument& mrDoc;
     SCTAB mnCurTab;
@@ -161,13 +161,13 @@ class SpanBroadcaster : public sc::ColumnSpanSet::ColumnAction
 public:
     SpanBroadcaster( ScDocument& rDoc ) : mrDoc(rDoc), mnCurTab(-1), mnCurCol(-1) {}
 
-    virtual void startColumn( ScColumn* pCol ) SAL_OVERRIDE
+    void startColumn( ScColumn* pCol )
     {
         mnCurTab = pCol->GetTab();
         mnCurCol = pCol->GetCol();
     }
 
-    virtual void execute( SCROW nRow1, SCROW nRow2, bool bVal ) SAL_OVERRIDE
+    void execute( SCROW nRow1, SCROW nRow2, bool bVal )
     {
         if (!bVal)
             return;


More information about the Libreoffice-commits mailing list