[Libreoffice-commits] core.git: sc/inc sc/source
Noel Grandin
noel.grandin at collabora.co.uk
Wed Jun 13 10:06:59 UTC 2018
sc/inc/columnspanset.hxx | 5 +---
sc/source/core/data/columnspanset.cxx | 42 ++++++++++++----------------------
2 files changed, 18 insertions(+), 29 deletions(-)
New commits:
commit 044b5d319cc8d337d819efddcc96dd2428961d2a
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Jun 13 10:08:24 2018 +0200
loplugin:useuniqueptr in ColumnSpanSet
Change-Id: Ic33454aa64116e1258362df1bd0ff3ddb05745af
Reviewed-on: https://gerrit.libreoffice.org/55734
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/inc/columnspanset.hxx b/sc/inc/columnspanset.hxx
index 8619cbc41aa4..17bccaa57236 100644
--- a/sc/inc/columnspanset.hxx
+++ b/sc/inc/columnspanset.hxx
@@ -59,10 +59,9 @@ private:
ColumnType(SCROW nStart, SCROW nEnd, bool bInit);
};
- typedef std::vector<ColumnType*> TableType;
- typedef std::vector<TableType*> DocType;
+ typedef std::vector<std::unique_ptr<ColumnType>> TableType;
- DocType maDoc;
+ std::vector<std::unique_ptr<TableType>> maTables;
bool mbInit;
ColumnType& getColumn(SCTAB nTab, SCCOL nCol);
diff --git a/sc/source/core/data/columnspanset.cxx b/sc/source/core/data/columnspanset.cxx
index d7d7718bbb84..f6b54d9314fc 100644
--- a/sc/source/core/data/columnspanset.cxx
+++ b/sc/source/core/data/columnspanset.cxx
@@ -60,32 +60,22 @@ ColumnSpanSet::ColumnSpanSet(bool bInit) : mbInit(bInit) {}
ColumnSpanSet::~ColumnSpanSet()
{
- DocType::iterator itTab = maDoc.begin(), itTabEnd = maDoc.end();
- for (; itTab != itTabEnd; ++itTab)
- {
- TableType* pTab = *itTab;
- if (!pTab)
- continue;
-
- std::for_each(pTab->begin(), pTab->end(), std::default_delete<ColumnType>());
- delete pTab;
- }
}
ColumnSpanSet::ColumnType& ColumnSpanSet::getColumn(SCTAB nTab, SCCOL nCol)
{
- if (static_cast<size_t>(nTab) >= maDoc.size())
- maDoc.resize(nTab+1, nullptr);
+ if (static_cast<size_t>(nTab) >= maTables.size())
+ maTables.resize(nTab+1);
- if (!maDoc[nTab])
- maDoc[nTab] = new TableType;
+ if (!maTables[nTab])
+ maTables[nTab].reset(new TableType);
- TableType& rTab = *maDoc[nTab];
+ TableType& rTab = *maTables[nTab];
if (static_cast<size_t>(nCol) >= rTab.size())
- rTab.resize(nCol+1, nullptr);
+ rTab.resize(nCol+1);
if (!rTab[nCol])
- rTab[nCol] = new ColumnType(0, MAXROW, mbInit);
+ rTab[nCol].reset(new ColumnType(0, MAXROW, mbInit));
return *rTab[nCol];
}
@@ -155,12 +145,12 @@ void ColumnSpanSet::scan(
void ColumnSpanSet::executeAction(Action& ac) const
{
- for (size_t nTab = 0; nTab < maDoc.size(); ++nTab)
+ for (size_t nTab = 0; nTab < maTables.size(); ++nTab)
{
- if (!maDoc[nTab])
+ if (!maTables[nTab])
continue;
- const TableType& rTab = *maDoc[nTab];
+ const TableType& rTab = *maTables[nTab];
for (size_t nCol = 0; nCol < rTab.size(); ++nCol)
{
if (!rTab[nCol])
@@ -186,12 +176,12 @@ void ColumnSpanSet::executeAction(Action& ac) const
void ColumnSpanSet::executeColumnAction(ScDocument& rDoc, ColumnAction& ac) const
{
- for (size_t nTab = 0; nTab < maDoc.size(); ++nTab)
+ for (size_t nTab = 0; nTab < maTables.size(); ++nTab)
{
- if (!maDoc[nTab])
+ if (!maTables[nTab])
continue;
- const TableType& rTab = *maDoc[nTab];
+ const TableType& rTab = *maTables[nTab];
for (size_t nCol = 0; nCol < rTab.size(); ++nCol)
{
if (!rTab[nCol])
@@ -229,12 +219,12 @@ void ColumnSpanSet::executeColumnAction(ScDocument& rDoc, ColumnAction& ac) cons
void ColumnSpanSet::executeColumnAction(ScDocument& rDoc, ColumnAction& ac, double& fMem) const
{
- for (size_t nTab = 0; nTab < maDoc.size(); ++nTab)
+ for (size_t nTab = 0; nTab < maTables.size(); ++nTab)
{
- if (!maDoc[nTab])
+ if (!maTables[nTab])
continue;
- const TableType& rTab = *maDoc[nTab];
+ const TableType& rTab = *maTables[nTab];
for (size_t nCol = 0; nCol < rTab.size(); ++nCol)
{
if (!rTab[nCol])
More information about the Libreoffice-commits
mailing list