[Libreoffice-commits] core.git: sc/inc sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Sep 28 07:01:39 UTC 2018
sc/inc/dpresfilter.hxx | 3 +--
sc/source/core/data/dpresfilter.cxx | 31 +++++++++++--------------------
2 files changed, 12 insertions(+), 22 deletions(-)
New commits:
commit 4ffb89466ff9e70678e807b7d29d94aa34d52bfe
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Sep 26 10:53:09 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Sep 28 09:01:16 2018 +0200
loplugin:useuniqueptr in ScDPResultTree::MemberNode
Change-Id: I835e37a99ddab174e45681fe6cf55edaa41a727c
Reviewed-on: https://gerrit.libreoffice.org/60995
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/inc/dpresfilter.hxx b/sc/inc/dpresfilter.hxx
index ddc69e647b70..ffccaa6dddc0 100644
--- a/sc/inc/dpresfilter.hxx
+++ b/sc/inc/dpresfilter.hxx
@@ -60,7 +60,6 @@ private:
struct MemberNode;
struct DimensionNode;
typedef std::map<OUString, std::shared_ptr<MemberNode> > MembersType;
- typedef std::map<OUString, DimensionNode*> DimensionsType;
struct DimensionNode
{
@@ -80,7 +79,7 @@ private:
struct MemberNode
{
ValuesType maValues;
- DimensionsType maChildDimensions;
+ std::map<OUString, std::unique_ptr<DimensionNode>> maChildDimensions;
MemberNode();
MemberNode(const MemberNode&) = delete;
diff --git a/sc/source/core/data/dpresfilter.cxx b/sc/source/core/data/dpresfilter.cxx
index 7ce394e1d293..2544d2f8f8b1 100644
--- a/sc/source/core/data/dpresfilter.cxx
+++ b/sc/source/core/data/dpresfilter.cxx
@@ -13,6 +13,7 @@
#include <unotools/charclass.hxx>
#include <rtl/math.hxx>
#include <sal/log.hxx>
+#include <o3tl/make_unique.hxx>
#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
@@ -59,12 +60,7 @@ void ScDPResultTree::DimensionNode::dump(int nLevel) const
ScDPResultTree::MemberNode::MemberNode() {}
-ScDPResultTree::MemberNode::~MemberNode()
-{
- DimensionsType::iterator it = maChildDimensions.begin(), itEnd = maChildDimensions.end();
- for (; it != itEnd; ++it)
- delete it->second;
-}
+ScDPResultTree::MemberNode::~MemberNode() {}
#if DEBUG_PIVOT_TABLE
void ScDPResultTree::MemberNode::dump(int nLevel) const
@@ -108,26 +104,21 @@ void ScDPResultTree::add(
maPrimaryDimName = filter.maDimName;
// See if this dimension exists.
- DimensionsType& rDims = pMemNode->maChildDimensions;
+ auto& rDims = pMemNode->maChildDimensions;
OUString aUpperName = ScGlobal::pCharClass->uppercase(filter.maDimName);
- DimensionsType::iterator itDim = rDims.find(aUpperName);
+ auto itDim = rDims.find(aUpperName);
if (itDim == rDims.end())
{
// New dimension. Insert it.
- std::pair<DimensionsType::iterator, bool> r =
- rDims.emplace(aUpperName, new DimensionNode);
-
- if (!r.second)
- // Insertion failed!
- return;
-
+ auto r = rDims.emplace(aUpperName, o3tl::make_unique<DimensionNode>());
+ assert(r.second);
itDim = r.first;
}
pDimName = &itDim->first;
// Now, see if this dimension member exists.
- DimensionNode* pDim = itDim->second;
+ DimensionNode* pDim = itDim->second.get();
MembersType& rMembersValueNames = pDim->maChildMembersValueNames;
aUpperName = ScGlobal::pCharClass->uppercase(filter.maValueName);
MembersType::iterator itMem = rMembersValueNames.find(aUpperName);
@@ -214,14 +205,14 @@ const ScDPResultTree::ValuesType* ScDPResultTree::getResults(
const MemberNode* pMember = mpRoot.get();
for (; p != pEnd; ++p)
{
- DimensionsType::const_iterator itDim = pMember->maChildDimensions.find(
+ auto itDim = pMember->maChildDimensions.find(
ScGlobal::pCharClass->uppercase(p->FieldName));
if (itDim == pMember->maChildDimensions.end())
// Specified dimension not found.
return nullptr;
- const DimensionNode* pDim = itDim->second;
+ const DimensionNode* pDim = itDim->second.get();
MembersType::const_iterator itMem( pDim->maChildMembersValueNames.find(
ScGlobal::pCharClass->uppercase( p->MatchValueName)));
@@ -246,8 +237,8 @@ const ScDPResultTree::ValuesType* ScDPResultTree::getResults(
const MemberNode* pFieldMember = pMember;
while (pFieldMember->maChildDimensions.size() == 1)
{
- DimensionsType::const_iterator itDim( pFieldMember->maChildDimensions.begin());
- const DimensionNode* pDim = itDim->second;
+ auto itDim( pFieldMember->maChildDimensions.begin());
+ const DimensionNode* pDim = itDim->second.get();
if (pDim->maChildMembersValueNames.size() != 1)
break; // while
pFieldMember = pDim->maChildMembersValueNames.begin()->second.get();
More information about the Libreoffice-commits
mailing list