[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Sep 12 07:05:45 UTC 2018


 sc/inc/document.hxx               |    2 +-
 sc/source/core/data/document.cxx  |    2 +-
 sc/source/core/tool/interpr4.cxx  |   29 ++++++-----------------------
 sw/source/core/access/accpara.cxx |    6 ++----
 4 files changed, 10 insertions(+), 29 deletions(-)

New commits:
commit 9b7ee5a05524b3c80258be6a0f6c5b496942d1f2
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Sep 11 15:53:16 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Sep 12 09:05:31 2018 +0200

    loplugin:useuniqueptr in SwAccessibleParagraph::_getRunAttributesImpl
    
    Change-Id: I6196d15ea4d83625c7f058ecf074a860e8ca6fe9
    Reviewed-on: https://gerrit.libreoffice.org/60355
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index bdd27f7ad03b..2e234a31d1fd 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -1875,7 +1875,7 @@ void SwAccessibleParagraph::_getRunAttributesImpl(
         tAccParaPropValMap& rRunAttrSeq )
 {
     // create PaM for character at position <nIndex>
-    SwPaM* pPaM( nullptr );
+    std::unique_ptr<SwPaM> pPaM;
     {
         const SwTextNode* pTextNode( GetTextNode() );
         std::unique_ptr<SwPosition> pStartPos( new SwPosition( *pTextNode ) );
@@ -1883,7 +1883,7 @@ void SwAccessibleParagraph::_getRunAttributesImpl(
         std::unique_ptr<SwPosition> pEndPos( new SwPosition( *pTextNode ) );
         pEndPos->nContent.Assign( const_cast<SwTextNode*>(pTextNode), nIndex+1 );
 
-        pPaM = new SwPaM( *pStartPos, *pEndPos );
+        pPaM.reset(new SwPaM( *pStartPos, *pEndPos ));
     }
 
     // retrieve character attributes for the created PaM <pPaM>
@@ -1972,8 +1972,6 @@ void SwAccessibleParagraph::_getRunAttributesImpl(
             }
         }
     }
-
-    delete pPaM;
 }
 
 uno::Sequence< PropertyValue > SwAccessibleParagraph::getRunAttributes(
commit ab974915f96c907e9270423adf332ab7910466c4
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Sep 11 15:39:30 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Sep 12 09:05:21 2018 +0200

    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 at collabora.co.uk>

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();
 }


More information about the Libreoffice-commits mailing list