diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-11-22 22:17:37 -0500 |
---|---|---|
committer | Ashod Nakashian <ashnakash@gmail.com> | 2017-11-29 14:05:10 +0100 |
commit | 7c8c2b5e3a569d60375975d6fbad32e3c3c48c9d (patch) | |
tree | 7eae3cea868ef44b02816e2994ef1936702f66fc | |
parent | ac5ecfeb5dd8578ca37876b6e0b23911d7cdae1c (diff) |
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@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
-rw-r--r-- | sc/Library_sc.mk | 1 | ||||
-rw-r--r-- | sc/inc/colcontainer.hxx | 35 | ||||
-rw-r--r-- | sc/source/core/data/colcontainer.cxx | 28 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 2 |
4 files changed, 23 insertions, 43 deletions
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 ), |