sc/source/core/data/table3.cxx |   23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

New commits:
commit 58966e16d8649a16fa961dbedc4f6f97693021e6
Author:     Takeshi Abe <t...@fixedpoint.jp>
AuthorDate: Wed Dec 19 17:24:45 2018 +0900
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Thu Dec 20 17:02:52 2018 +0100

    sc: Simplify RemoveSubTotalsHandler using std::set
    
    instead of std::vector.
    
    Change-Id: I5927e061b5d2944cad68b96e313934738c63c321
    Reviewed-on: https://gerrit.libreoffice.org/65400
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <er...@redhat.com>

diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 5a2550ce0ead..48952234341d 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -69,6 +69,7 @@
 #include <svl/sharedstringpool.hxx>
 
 #include <memory>
+#include <set>
 #include <unordered_set>
 #include <vector>
 #include <mdds/flat_segment_tree.hpp>
@@ -1864,25 +1865,14 @@ bool ScTable::TestRemoveSubTotals( const 
ScSubTotalParam& rParam )
 
 namespace {
 
-class RemoveSubTotalsHandler
+struct RemoveSubTotalsHandler
 {
-    std::vector<SCROW> maRemoved;
-public:
+    std::set<SCROW> aRemoved;
 
     void operator() (size_t nRow, const ScFormulaCell* p)
     {
         if (p->IsSubTotal())
-            maRemoved.push_back(nRow);
-    }
-
-    void getRows(std::vector<SCROW>& rRows)
-    {
-        // Sort and remove duplicates.
-        std::sort(maRemoved.begin(), maRemoved.end());
-        std::vector<SCROW>::iterator it = std::unique(maRemoved.begin(), 
maRemoved.end());
-        maRemoved.erase(it, maRemoved.end());
-
-        maRemoved.swap(rRows);
+            aRemoved.insert(nRow);
     }
 };
 
@@ -1902,10 +1892,9 @@ void ScTable::RemoveSubTotals( ScSubTotalParam& rParam )
         sc::ParseFormula(rCells.begin(), rCells, nStartRow, nEndRow, aFunc);
     }
 
-    std::vector<SCROW> aRows;
-    aFunc.getRows(aRows);
+    auto& aRows = aFunc.aRemoved;
 
-    std::vector<SCROW>::reverse_iterator it = aRows.rbegin(), itEnd = 
aRows.rend();
+    auto it = aRows.rbegin(), itEnd = aRows.rend();
     for (; it != itEnd; ++it)
     {
         SCROW nRow = *it;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to