diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-11 15:39:30 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-12 09:05:21 +0200 |
commit | ab974915f96c907e9270423adf332ab7910466c4 (patch) | |
tree | 8608c307df0bb5d4778ea299607cc7158cedbdf4 /sc | |
parent | c72b9281d5a2b199143d56c58f8ddabf466968a2 (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')
-rw-r--r-- | sc/inc/document.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 29 |
3 files changed, 8 insertions, 25 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 1bb1f65aab3c..931188800862 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -427,7 +427,7 @@ private: mxVbaEvents; public: /// list of ScInterpreterTableOpParams currently in use - std::vector<std::unique_ptr<ScInterpreterTableOpParams>> m_TableOpList; + std::vector<ScInterpreterTableOpParams*> m_TableOpList; ScInterpreterTableOpParams aLastTableOpParams; // remember last params private: diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 59c821e4764a..6b6723921fae 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -3920,7 +3920,7 @@ void ScDocument::AddTableOpFormulaCell( ScFormulaCell* pCell ) { if (!m_TableOpList.empty()) { - ScInterpreterTableOpParams *const p = m_TableOpList.back().get(); + ScInterpreterTableOpParams *const p = m_TableOpList.back(); if ( p->bCollectNotifications ) { if ( p->bRefresh ) 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(); } |