[Libreoffice-commits] core.git: Branch 'distro/collabora/cd-5.3' - sc/inc sc/Library_sc.mk sc/source

Ashod Nakashian ashod.nakashian at collabora.co.uk
Wed Nov 29 13:05:42 UTC 2017


 sc/Library_sc.mk                     |    1 -
 sc/inc/colcontainer.hxx              |   35 ++++++++++++++++++++++-------------
 sc/source/core/data/colcontainer.cxx |   28 ----------------------------
 sc/source/core/data/table1.cxx       |    2 +-
 4 files changed, 23 insertions(+), 43 deletions(-)

New commits:
commit 7c8c2b5e3a569d60375975d6fbad32e3c3c48c9d
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Wed Nov 22 22:17:37 2017 -0500

    sc: simplify ScColContainer
    
    Less clutter, no indirection and smaller memory footprint.
    
    Change-Id: Ic24272e9853a7af28df62298fd26e7edce554986
    Reviewed-on: https://gerrit.libreoffice.org/45379
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 329fe87840b8..a36b6a9fc37e 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -107,7 +107,6 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
     sc/source/core/data/cellvalues \
     sc/source/core/data/clipcontext \
     sc/source/core/data/clipparam \
-    sc/source/core/data/colcontainer \
     sc/source/core/data/column \
     sc/source/core/data/column2 \
     sc/source/core/data/column3 \
diff --git a/sc/inc/colcontainer.hxx b/sc/inc/colcontainer.hxx
index 0f4a64589cdd..8165c6ff42ff 100644
--- a/sc/inc/colcontainer.hxx
+++ b/sc/inc/colcontainer.hxx
@@ -22,30 +22,34 @@
 
 #include "types.hxx"
 #include "address.hxx"
+#include "column.hxx"
 
 #include <vector>
 
-class ScColumn;
-class ScDocument;
-
-class ScColContainer
+class ScColContainer final
 {
-    typedef std::vector<ScColumn*> ScColumnVector;
-    ScColumnVector    aCols;
-    ScDocument*       pDocument;
+    std::vector<ScColumn> aCols;
 
 public:
-    ScColContainer( ScDocument* pDoc, const size_t nSize );
-    ~ScColContainer();
+
+    ScColContainer(const size_t nSize)
+      : aCols(nSize)
+    {
+    }
+
+    ~ScColContainer()
+    {
+        Clear();
+    }
 
     const ScColumn& operator[] ( const size_t nIndex ) const
     {
-        return *aCols[nIndex];
+        return aCols[nIndex];
     }
 
     ScColumn& operator[] ( const size_t nIndex )
     {
-        return *aCols[nIndex];
+        return aCols[nIndex];
     }
 
     SCCOL size() const
@@ -58,9 +62,14 @@ public:
         return aCols.empty();
     }
 
-    void Clear();
-};
+    void Clear()
+    {
+        for (ScColumn& rCol: aCols)
+            rCol.PrepareBroadcastersForDestruction();
 
+        aCols.clear();
+    }
+};
 
 #endif
 
diff --git a/sc/source/core/data/colcontainer.cxx b/sc/source/core/data/colcontainer.cxx
index 7433240c8999..b2f93e975edd 100644
--- a/sc/source/core/data/colcontainer.cxx
+++ b/sc/source/core/data/colcontainer.cxx
@@ -18,32 +18,4 @@
  */
 
 
-#include "colcontainer.hxx"
-#include "column.hxx"
-#include "document.hxx"
-
-ScColContainer::ScColContainer( ScDocument* pDoc, const size_t nSize )
-{
-    pDocument = pDoc;
-    aCols.resize( nSize );
-    for ( size_t nCol = 0; nCol < nSize; ++nCol )
-        aCols[nCol] = new ScColumn;
-}
-
-ScColContainer::~ScColContainer()
-{
-    Clear();
-}
-
-
-void ScColContainer::Clear()
-{
-    SCCOL nSize = size();
-    for ( SCCOL nIdx = 0; nIdx < nSize; ++nIdx )
-    {
-        aCols[nIdx]->PrepareBroadcastersForDestruction();
-        delete aCols[nIdx];
-    }
-    aCols.clear();
-}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 7e54e1e16743..472078f5ea21 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -237,7 +237,7 @@ bool SetOptimalHeightsToRows(
 
 ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
                     bool bColInfo, bool bRowInfo ) :
-    aCol( pDoc, MAXCOLCOUNT ),
+    aCol( MAXCOLCOUNT ),
     aName( rNewName ),
     aCodeName( rNewName ),
     nLinkRefreshDelay( 0 ),


More information about the Libreoffice-commits mailing list