summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2018-12-19 17:24:45 +0900
committerEike Rathke <erack@redhat.com>2018-12-20 17:02:52 +0100
commit58966e16d8649a16fa961dbedc4f6f97693021e6 (patch)
tree3fd964168684dbf69870224ec11f7ad616b7ae2e /sc
parentcab88e6fa6ae810a853c57ab427de3a3691828d4 (diff)
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 <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/table3.cxx23
1 files changed, 6 insertions, 17 deletions
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;