summaryrefslogtreecommitdiff
path: root/sc/source/core/tool/interpr4.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-09-11 15:39:30 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-12 09:05:21 +0200
commitab974915f96c907e9270423adf332ab7910466c4 (patch)
tree8608c307df0bb5d4778ea299607cc7158cedbdf4 /sc/source/core/tool/interpr4.cxx
parentc72b9281d5a2b199143d56c58f8ddabf466968a2 (diff)
loplugin:useuniqueptr in ScInterpreter
the ScInterpreterTableOpParams are allocated and deleted in the same method, so the vector in ScDocument doesn't actually need to own them Change-Id: Icd5a33c891e608abc0843c144d7a53f44c3ac02f Reviewed-on: https://gerrit.libreoffice.org/60354 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/core/tool/interpr4.cxx')
-rw-r--r--sc/source/core/tool/interpr4.cxx29
1 files changed, 6 insertions, 23 deletions
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 7f5b5a81d490..4b5ff2281bfa 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -92,7 +92,7 @@ void ScInterpreter::ReplaceCell( ScAddress& rPos )
size_t ListSize = pDok->m_TableOpList.size();
for ( size_t i = 0; i < ListSize; ++i )
{
- ScInterpreterTableOpParams *const pTOp = pDok->m_TableOpList[ i ].get();
+ ScInterpreterTableOpParams *const pTOp = pDok->m_TableOpList[ i ];
if ( rPos == pTOp->aOld1 )
{
rPos = pTOp->aNew1;
@@ -115,7 +115,7 @@ bool ScInterpreter::IsTableOpInRange( const ScRange& rRange )
size_t ListSize = pDok->m_TableOpList.size();
for ( size_t i = 0; i < ListSize; ++i )
{
- ScInterpreterTableOpParams *const pTOp = pDok->m_TableOpList[ i ].get();
+ ScInterpreterTableOpParams *const pTOp = pDok->m_TableOpList[ i ];
if ( rRange.In( pTOp->aOld1 ) )
return true;
if ( rRange.In( pTOp->aOld2 ) )
@@ -3533,21 +3533,6 @@ bool ScInterpreter::SetSbxVariable( SbxVariable* pVar, const ScAddress& rPos )
#endif
-namespace {
-
-class FindByPointer
-{
- const ScInterpreterTableOpParams* mpTableOp;
-public:
- explicit FindByPointer(const ScInterpreterTableOpParams* p) : mpTableOp(p) {}
- bool operator() (std::unique_ptr<ScInterpreterTableOpParams> const& val) const
- {
- return val.get() == mpTableOp;
- }
-};
-
-}
-
void ScInterpreter::ScTableOp()
{
sal_uInt8 nParamCount = GetByte();
@@ -3556,7 +3541,7 @@ void ScInterpreter::ScTableOp()
PushIllegalParameter();
return;
}
- ScInterpreterTableOpParams* pTableOp = new ScInterpreterTableOpParams;
+ std::unique_ptr<ScInterpreterTableOpParams> pTableOp(new ScInterpreterTableOpParams);
if (nParamCount == 5)
{
PopSingleRef( pTableOp->aNew2 );
@@ -3567,8 +3552,7 @@ void ScInterpreter::ScTableOp()
PopSingleRef( pTableOp->aFormulaPos );
pTableOp->bValid = true;
- pDok->m_TableOpList.push_back(
- std::unique_ptr<ScInterpreterTableOpParams>(pTableOp));
+ pDok->m_TableOpList.push_back(pTableOp.get());
pDok->IncInterpreterTableOpLevel();
bool bReuseLastParams = (pDok->aLastTableOpParams == *pTableOp);
@@ -3609,10 +3593,9 @@ void ScInterpreter::ScTableOp()
}
auto const itr =
- ::std::find_if(pDok->m_TableOpList.begin(), pDok->m_TableOpList.end(), FindByPointer(pTableOp));
+ ::std::find(pDok->m_TableOpList.begin(), pDok->m_TableOpList.end(), pTableOp.get());
if (itr != pDok->m_TableOpList.end())
{
- pTableOp = itr->release();
pDok->m_TableOpList.erase(itr);
}
@@ -3645,7 +3628,7 @@ void ScInterpreter::ScTableOp()
{
(*iBroadcast2)->ResetTableOpDirtyVar();
}
- delete pTableOp;
+ pTableOp.reset();
pDok->DecInterpreterTableOpLevel();
}