Kaydet (Commit) 58966e16 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Eike Rathke

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: 's avatarEike Rathke <erack@redhat.com>
üst cab88e6f
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment