summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-04-03 14:05:20 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-04-04 08:30:00 +0200
commit9d037cb837d74708358168333a0b457952de23a6 (patch)
tree6777f336999272664d824d4b264453c5cecb8be7 /sc
parentb7f6dc5957ac615f38b26d6e0147306cac1c3d7b (diff)
loplugin:useuniqueptr in ScJumpMatrix
Change-Id: Ia8461773bdb2290690616b291356edd3a9ea4f35 Reviewed-on: https://gerrit.libreoffice.org/52341 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/inc/jumpmatrix.hxx6
-rw-r--r--sc/source/core/tool/interpr1.cxx15
-rw-r--r--sc/source/core/tool/interpr4.cxx6
-rw-r--r--sc/source/core/tool/jumpmatrix.cxx17
4 files changed, 16 insertions, 28 deletions
diff --git a/sc/source/core/inc/jumpmatrix.hxx b/sc/source/core/inc/jumpmatrix.hxx
index 084f5a91f4bb..c4a0b5784896 100644
--- a/sc/source/core/inc/jumpmatrix.hxx
+++ b/sc/source/core/inc/jumpmatrix.hxx
@@ -60,7 +60,7 @@ class ScJumpMatrix
std::vector<ScJumpMatrixEntry> mvJump; // the jumps
ScMatrixRef pMat; // the results
ScRefList mvRefList; // array of references result, if any
- ScTokenVec* pParams; // parameter stack
+ ScTokenVec mvParams; // parameter stack
SCSIZE nCols;
SCSIZE nRows;
SCSIZE nCurCol;
@@ -103,8 +103,8 @@ public:
void SetJump( SCSIZE nCol, SCSIZE nRow, double fBool, short nStart, short nNext );
void GetJump( SCSIZE nCol, SCSIZE nRow, double& rBool, short& rStart, short& rNext, short& rStop ) const;
void SetAllJumps( double fBool, short nStart, short nNext, short nStop = SHRT_MAX );
- void SetJumpParameters( ScTokenVec* p );
- const ScTokenVec* GetJumpParameters() const { return pParams;}
+ void SetJumpParameters( ScTokenVec&& p );
+ const ScTokenVec & GetJumpParameters() const { return mvParams;}
bool HasResultMatrix() const;
ScMatrix* GetResultMatrix(); ///< also applies pending buffered values
void GetPos( SCSIZE& rCol, SCSIZE& rRow ) const;
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 06fc60b8a18e..51a2a422abfc 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -786,16 +786,13 @@ bool ScInterpreter::JumpMatrix( short nStackLevel )
}
if ( bCont && nStart != nNext )
{
- const ScTokenVec* pParams = pJumpMatrix->GetJumpParameters();
- if ( pParams )
+ const ScTokenVec & rParams = pJumpMatrix->GetJumpParameters();
+ for ( auto const & i : rParams )
{
- for ( ScTokenVec::const_iterator i = pParams->begin(); i != pParams->end(); ++i )
- {
- // This is not the current state of the interpreter, so
- // push without error, and elements' errors are coded into
- // double.
- PushWithoutError( *(*i));
- }
+ // This is not the current state of the interpreter, so
+ // push without error, and elements' errors are coded into
+ // double.
+ PushWithoutError(*i);
}
aCode.Jump( nStart, nNext, nStop );
}
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index e631ffaf9139..d28d8138a88a 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -1576,15 +1576,15 @@ bool ScInterpreter::ConvertMatrixParameters()
std::unique_ptr<ScJumpMatrix> pJumpMat( new ScJumpMatrix( pCur->GetOpCode(), nJumpCols, nJumpRows));
pJumpMat->SetAllJumps( 1.0, nStart, nNext, nStop);
// pop parameters and store in ScJumpMatrix, push in JumpMatrix()
- ScTokenVec* pParams = new ScTokenVec( nParams);
+ ScTokenVec aParams(nParams);
for ( sal_uInt16 i=1; i <= nParams && sp > 0; ++i )
{
const FormulaToken* p = pStack[ --sp ];
p->IncRef();
// store in reverse order such that a push may simply iterate
- (*pParams)[ nParams - i ] = p;
+ aParams[ nParams - i ] = p;
}
- pJumpMat->SetJumpParameters( pParams);
+ pJumpMat->SetJumpParameters( std::move(aParams) );
xNew = new ScJumpMatrixToken( std::move(pJumpMat) );
GetTokenMatrixMap().emplace(pCur, xNew);
}
diff --git a/sc/source/core/tool/jumpmatrix.cxx b/sc/source/core/tool/jumpmatrix.cxx
index ed71c69c1a20..c3153fd5ac3e 100644
--- a/sc/source/core/tool/jumpmatrix.cxx
+++ b/sc/source/core/tool/jumpmatrix.cxx
@@ -30,7 +30,6 @@ const SCSIZE kBufferThreshold = 128;
ScJumpMatrix::ScJumpMatrix( OpCode eOp, SCSIZE nColsP, SCSIZE nRowsP )
: mvJump(nColsP * nRowsP)
, pMat(new ScFullMatrix(nColsP, nRowsP))
- , pParams(nullptr)
, nCols(nColsP)
, nRows(nRowsP)
, nCurCol(0)
@@ -53,16 +52,8 @@ ScJumpMatrix::ScJumpMatrix( OpCode eOp, SCSIZE nColsP, SCSIZE nRowsP )
ScJumpMatrix::~ScJumpMatrix()
{
- if (pParams)
- {
- for (ScTokenVec::iterator i =
- pParams->begin(); i !=
- pParams->end(); ++i)
- {
- (*i)->DecRef();
- }
- delete pParams;
- }
+ for (auto & i : mvParams)
+ i->DecRef();
}
void ScJumpMatrix::GetDimensions(SCSIZE& rCols, SCSIZE& rRows) const
@@ -107,9 +98,9 @@ void ScJumpMatrix::SetAllJumps(double fBool, short nStart, short nNext, short nS
}
}
-void ScJumpMatrix::SetJumpParameters(ScTokenVec* p)
+void ScJumpMatrix::SetJumpParameters(ScTokenVec&& p)
{
- pParams = p;
+ mvParams = std::move(p);
}
void ScJumpMatrix::GetPos(SCSIZE& rCol, SCSIZE& rRow) const