[Libreoffice-commits] core.git: sc/inc sc/qa sc/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Jul 21 19:49:07 UTC 2021


 sc/inc/column.hxx                      |    3 ++-
 sc/inc/columniterator.hxx              |    1 -
 sc/inc/document.hxx                    |    3 ++-
 sc/inc/table.hxx                       |    3 ++-
 sc/qa/unit/ucalc.cxx                   |    2 +-
 sc/source/core/data/column4.cxx        |    6 +++---
 sc/source/core/data/columniterator.cxx |    2 --
 sc/source/core/data/document10.cxx     |    4 ++--
 sc/source/core/data/dpcache.cxx        |    2 +-
 sc/source/core/data/table7.cxx         |    4 ++--
 10 files changed, 15 insertions(+), 15 deletions(-)

New commits:
commit 697e9f3cc9cb3309bf7e22bc39057ff720f1d1b3
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jul 21 11:40:27 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jul 21 21:48:25 2021 +0200

    pass sc::ColumnIterator by value
    
    no need to allocate on heap
    
    Change-Id: Ie0f3fa39092083b9c30f3e769bb65fa975150021
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119312
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 20ae065c1613..01cf0da1f404 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -30,6 +30,7 @@
 #include <svx/svdobj.hxx>
 #include "attarray.hxx"
 
+#include <optional>
 #include <set>
 #include <vector>
 
@@ -704,7 +705,7 @@ public:
     void SwapNonEmpty(
         sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt );
 
-    std::unique_ptr<sc::ColumnIterator> GetColumnIterator( SCROW nRow1, SCROW nRow2 ) const;
+    std::optional<sc::ColumnIterator> GetColumnIterator( SCROW nRow1, SCROW nRow2 ) const;
 
     bool EnsureFormulaCellResults( SCROW nRow1, SCROW nRow2, bool bSkipRunning = false );
 
diff --git a/sc/inc/columniterator.hxx b/sc/inc/columniterator.hxx
index 5cf57e0f438b..64ea55e31325 100644
--- a/sc/inc/columniterator.hxx
+++ b/sc/inc/columniterator.hxx
@@ -71,7 +71,6 @@ class ColumnIterator
 
 public:
     ColumnIterator(const CellStoreType& rCells, SCROW nRow1, SCROW nRow2);
-    ~ColumnIterator();
 
     void next();
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 63aec33a5161..84be212a2045 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -47,6 +47,7 @@
 #include <cassert>
 #include <memory>
 #include <map>
+#include <optional>
 #include <set>
 #include <unordered_map>
 #include <vector>
@@ -2512,7 +2513,7 @@ public:
     const SvtBroadcaster*   GetBroadcaster( const ScAddress& rPos ) const;
     void                    DeleteBroadcasters( sc::ColumnBlockPosition& rBlockPos, const ScAddress& rTopPos, SCROW nLength );
 
-    std::unique_ptr<sc::ColumnIterator> GetColumnIterator( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
+    std::optional<sc::ColumnIterator> GetColumnIterator( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
     void CreateColumnIfNotExists( SCTAB nTab, SCCOL nCol );
 
     SC_DLLPUBLIC void StoreTabToCache(SCTAB nTab, SvStream& rStrm) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 1f68937f87d2..6ecc0746d7b5 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -35,6 +35,7 @@
 #include "document.hxx"
 #include "drwlayer.hxx"
 
+#include <optional>
 #include <set>
 #include <memory>
 
@@ -1061,7 +1062,7 @@ public:
     void TransferCellValuesTo( const SCCOL nCol, SCROW nRow, size_t nLen, sc::CellValues& rDest );
     void CopyCellValuesFrom( const SCCOL nCol, SCROW nRow, const sc::CellValues& rSrc );
 
-    std::unique_ptr<sc::ColumnIterator> GetColumnIterator( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
+    std::optional<sc::ColumnIterator> GetColumnIterator( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
 
     bool EnsureFormulaCellResults( const SCCOL nCol1, SCROW nRow1, const SCCOL nCol2, SCROW nRow2, bool bSkipRunning = false );
 
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 75e96eba3c70..5f2145714e3a 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -667,7 +667,7 @@ void Test::testColumnIterator() // tdf#118620
 
     m_pDoc->SetString(0, 0, 0, "'10.5");
     m_pDoc->SetString(0, MAXROW-5, 0, "42.0");
-    std::unique_ptr<sc::ColumnIterator> it = m_pDoc->GetColumnIterator(0, 0, MAXROW - 10, MAXROW);
+    std::optional<sc::ColumnIterator> it = m_pDoc->GetColumnIterator(0, 0, MAXROW - 10, MAXROW);
     while (it->hasCell())
     {
         it->getCell();
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 54213f2cd582..b490c557dfe0 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -1663,12 +1663,12 @@ void ScColumn::SetNeedsListeningGroup( SCROW nRow )
         (*pp)->SetNeedsListening(true);
 }
 
-std::unique_ptr<sc::ColumnIterator> ScColumn::GetColumnIterator( SCROW nRow1, SCROW nRow2 ) const
+std::optional<sc::ColumnIterator> ScColumn::GetColumnIterator( SCROW nRow1, SCROW nRow2 ) const
 {
     if (!GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2) || nRow1 > nRow2)
-        return std::unique_ptr<sc::ColumnIterator>();
+        return {};
 
-    return std::make_unique<sc::ColumnIterator>(maCells, nRow1, nRow2);
+    return sc::ColumnIterator(maCells, nRow1, nRow2);
 }
 
 static bool lcl_InterpretSpan(sc::formula_block::const_iterator& rSpanIter, SCROW nStartOffset, SCROW nEndOffset,
diff --git a/sc/source/core/data/columniterator.cxx b/sc/source/core/data/columniterator.cxx
index a65541fabb53..cec8f7a2028e 100644
--- a/sc/source/core/data/columniterator.cxx
+++ b/sc/source/core/data/columniterator.cxx
@@ -176,8 +176,6 @@ ColumnIterator::ColumnIterator( const CellStoreType& rCells, SCROW nRow1, SCROW
 {
 }
 
-ColumnIterator::~ColumnIterator() {}
-
 void ColumnIterator::next()
 {
     if ( maPos == maPosEnd)
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index 81f2fe11bc83..f2c8ef5be794 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -963,11 +963,11 @@ bool ScDocument::IsEditActionAllowed(
         [this, &eAction, &nStart, &nEnd](const SCTAB& rTab) { return IsEditActionAllowed(eAction, rTab, nStart, nEnd); });
 }
 
-std::unique_ptr<sc::ColumnIterator> ScDocument::GetColumnIterator( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const
+std::optional<sc::ColumnIterator> ScDocument::GetColumnIterator( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const
 {
     const ScTable* pTab = FetchTable(nTab);
     if (!pTab)
-        return std::unique_ptr<sc::ColumnIterator>();
+        return {};
 
     return pTab->GetColumnIterator(nCol, nRow1, nRow2);
 }
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index f1c32e376091..441f8e798c2a 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -391,7 +391,7 @@ void initColumnFromDoc( InitDocData& rDocData, InitColumnData &rColData )
     SCROW nEndRow = rDocData.mnEndRow;
     bool bTailEmptyRows = rDocData.mbTailEmptyRows;
 
-    std::unique_ptr<sc::ColumnIterator> pIter =
+    std::optional<sc::ColumnIterator> pIter =
         rDoc.GetColumnIterator(nDocTab, nCol, nStartRow, nEndRow);
     assert(pIter);
     assert(pIter->hasCell());
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index 2ab726ed6a98..b66b9d88eb3a 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -422,10 +422,10 @@ bool ScTable::IsEditActionAllowed(
     return false;
 }
 
-std::unique_ptr<sc::ColumnIterator> ScTable::GetColumnIterator( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const
+std::optional<sc::ColumnIterator> ScTable::GetColumnIterator( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const
 {
     if (!ValidCol(nCol))
-        return std::unique_ptr<sc::ColumnIterator>();
+        return {};
 
     return CreateColumnIfNotExists(nCol).GetColumnIterator(nRow1, nRow2);
 }


More information about the Libreoffice-commits mailing list