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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 22 06:58:46 UTC 2021


 sc/source/core/inc/interpre.hxx  |    7 ++-----
 sc/source/core/tool/interpr1.cxx |   22 ++++++++--------------
 sc/source/core/tool/interpr4.cxx |   20 +++++++-------------
 sc/source/core/tool/interpr5.cxx |    6 +++---
 4 files changed, 20 insertions(+), 35 deletions(-)

New commits:
commit ccb60734bd30115affa835cb189fcd3ca21306a9
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jul 21 14:52:16 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 22 08:58:04 2021 +0200

    no need to allocate ScTokenMatrixMap separately
    
    Change-Id: I2345b7b5c9b21aac06b557658906e8028fadec0a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119333
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index c7b93798bc58..322b2e32d5a0 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -198,7 +198,7 @@ private:
     svl::SharedStringPool& mrStrPool;
     formula::FormulaConstTokenRef  xResult;
     ScJumpMatrix*   pJumpMatrix;        // currently active array condition, if any
-    std::unique_ptr<ScTokenMatrixMap> pTokenMatrixMap;  // map FormulaToken* to formula::FormulaTokenRef if in array condition
+    ScTokenMatrixMap maTokenMatrixMap;  // map FormulaToken* to formula::FormulaTokenRef if in array condition
     ScFormulaCell* pMyFormulaCell;      // the cell of this formula expression
     SvNumberFormatter* pFormatter;
 
@@ -450,7 +450,6 @@ private:
             SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
             SCCOL nCol2, SCROW nRow2, SCTAB nTab2 );
     inline ScTokenMatrixMap& GetTokenMatrixMap();
-    static std::unique_ptr<ScTokenMatrixMap> CreateTokenMatrixMap();
     ScMatrixRef GetMatrix();
     ScMatrixRef GetMatrix( short & rParam, size_t & rInRefList );
     sc::RangeMatrix GetRangeMatrix();
@@ -1050,9 +1049,7 @@ inline bool ScInterpreter::MatrixParameterConversion()
 
 inline ScTokenMatrixMap& ScInterpreter::GetTokenMatrixMap()
 {
-    if (!pTokenMatrixMap)
-        pTokenMatrixMap = CreateTokenMatrixMap();
-    return *pTokenMatrixMap;
+    return maTokenMatrixMap;
 }
 
 inline bool ScInterpreter::MustHaveParamCount( short nAct, short nMust )
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index f0bcf7b913fa..63493b9c09c7 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -106,7 +106,7 @@ void ScInterpreter::ScIfJump()
                     PushIllegalArgument();
                     return;
                 }
-                else if (pTokenMatrixMap && ((aMapIter = pTokenMatrixMap->find( pCur)) != pTokenMatrixMap->end()))
+                else if ((aMapIter = maTokenMatrixMap.find( pCur)) != maTokenMatrixMap.end())
                     xNew = (*aMapIter).second;
                 else
                 {
@@ -335,7 +335,7 @@ void ScInterpreter::ScIfError( bool bNAonly )
 
                 FormulaConstTokenRef xNew;
                 ScTokenMatrixMap::const_iterator aMapIter;
-                if (pTokenMatrixMap && ((aMapIter = pTokenMatrixMap->find( pCur)) != pTokenMatrixMap->end()))
+                if ((aMapIter = maTokenMatrixMap.find( pCur)) != maTokenMatrixMap.end())
                 {
                     xNew = (*aMapIter).second;
                 }
@@ -429,8 +429,8 @@ void ScInterpreter::ScChooseJump()
                 pMat->GetDimensions( nCols, nRows );
                 if ( nCols == 0 || nRows == 0 )
                     PushIllegalParameter();
-                else if (pTokenMatrixMap && ((aMapIter = pTokenMatrixMap->find(
-                                    pCur)) != pTokenMatrixMap->end()))
+                else if ((aMapIter = maTokenMatrixMap.find(
+                                    pCur)) != maTokenMatrixMap.end())
                     xNew = (*aMapIter).second;
                 else
                 {
@@ -854,11 +854,8 @@ bool ScInterpreter::JumpMatrix( short nStackLevel )
             pJumpMatrix = nullptr;
             Pop();
             PushTokenRef( xRef);
-            if (pTokenMatrixMap)
-            {
-                pTokenMatrixMap->erase( pCur);
-                // There's no result matrix to remember in this case.
-            }
+            maTokenMatrixMap.erase( pCur);
+            // There's no result matrix to remember in this case.
         }
         else
         {
@@ -868,11 +865,8 @@ bool ScInterpreter::JumpMatrix( short nStackLevel )
             PushMatrix( pResMat );
             // Remove jump matrix from map and remember result matrix in case it
             // could be reused in another path of the same condition.
-            if (pTokenMatrixMap)
-            {
-                pTokenMatrixMap->erase( pCur);
-                pTokenMatrixMap->emplace(pCur, pStack[sp-1]);
-            }
+            maTokenMatrixMap.erase( pCur);
+            maTokenMatrixMap.emplace(pCur, pStack[sp-1]);
         }
         return true;
     }
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 289c06b43323..0afa2778b825 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -1428,11 +1428,6 @@ void ScInterpreter::ConvertMatrixJumpConditionToMatrix()
         PushIllegalParameter();
 }
 
-std::unique_ptr<ScTokenMatrixMap> ScInterpreter::CreateTokenMatrixMap()
-{
-    return std::make_unique<ScTokenMatrixMap>();
-}
-
 bool ScInterpreter::ConvertMatrixParameters()
 {
     sal_uInt16 nParams = pCur->GetParamCount();
@@ -1580,7 +1575,7 @@ bool ScInterpreter::ConvertMatrixParameters()
         short nStop = nPC + 1;      // stop subroutine before reaching that
         FormulaConstTokenRef xNew;
         ScTokenMatrixMap::const_iterator aMapIter;
-        if (pTokenMatrixMap && ((aMapIter = pTokenMatrixMap->find( pCur)) != pTokenMatrixMap->end()))
+        if ((aMapIter = maTokenMatrixMap.find( pCur)) != maTokenMatrixMap.end())
             xNew = (*aMapIter).second;
         else
         {
@@ -3840,7 +3835,7 @@ void ScInterpreter::Init( ScFormulaCell* pCell, const ScAddress& rPos, ScTokenAr
     pArr = &rTokArray;
     xResult = nullptr;
     pJumpMatrix = nullptr;
-    pTokenMatrixMap.reset();
+    maTokenMatrixMap.clear();
     pMyFormulaCell = pCell;
     pCur = nullptr;
     nGlobalError = FormulaError::NONE;
@@ -3980,10 +3975,9 @@ StackVar ScInterpreter::Interpret()
             PushWithoutError( *pCur );
             nCurFmtType = SvNumFormatType::UNDEFINED;
         }
-        else if (pTokenMatrixMap &&
-                 !FormulaCompiler::IsOpCodeJumpCommand( eOp ) &&
-                ((aTokenMatrixMapIter = pTokenMatrixMap->find( pCur)) !=
-                 pTokenMatrixMap->end()) &&
+        else if (!FormulaCompiler::IsOpCodeJumpCommand( eOp ) &&
+                ((aTokenMatrixMapIter = maTokenMatrixMap.find( pCur)) !=
+                 maTokenMatrixMap.end()) &&
                 (*aTokenMatrixMapIter).second->GetType() != svJumpMatrix)
         {
             // Path already calculated, reuse result.
@@ -4466,8 +4460,8 @@ StackVar ScInterpreter::Interpret()
                 meVolatileType = VOLATILE;
 
             // Remember result matrix in case it could be reused.
-            if (pTokenMatrixMap && sp && GetStackType() == svMatrix)
-                pTokenMatrixMap->emplace(pCur, pStack[sp-1]);
+            if (sp && GetStackType() == svMatrix)
+                maTokenMatrixMap.emplace(pCur, pStack[sp-1]);
 
             // outer function determines format of an expression
             if ( nFuncFmtType != SvNumFormatType::UNDEFINED )
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 1e16518ae8da..5daca41f5e24 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -350,7 +350,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken
     }
 
     ScTokenMatrixMap::const_iterator aIter;
-    if (pToken && pTokenMatrixMap && ((aIter = pTokenMatrixMap->find( pToken)) != pTokenMatrixMap->end()))
+    if (pToken && ((aIter = maTokenMatrixMap.find( pToken)) != maTokenMatrixMap.end()))
     {
         /* XXX casting const away here is ugly; ScMatrixToken (to which the
          * result of this function usually is assigned) should not be forced to
@@ -468,8 +468,8 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken
         }
     }
 
-    if (pToken && pTokenMatrixMap)
-        pTokenMatrixMap->emplace(pToken, new ScMatrixToken( pMat));
+    if (pToken)
+        maTokenMatrixMap.emplace(pToken, new ScMatrixToken( pMat));
 
     return pMat;
 }


More information about the Libreoffice-commits mailing list