Kaydet (Commit) 1da9761c authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in ImplHomMatrixTemplate

Change-Id: I31175a5110672e864b07d6b5508b8b04b14e66ee
Reviewed-on: https://gerrit.libreoffice.org/58484
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 5934d4ab
......@@ -75,7 +75,7 @@ namespace basegfx
template < sal_uInt16 RowSize > class ImplHomMatrixTemplate
{
ImplMatLine< RowSize > maLine[RowSize - 1];
ImplMatLine< RowSize >* mpLine;
std::unique_ptr<ImplMatLine< RowSize >> mutable mpLine;
public:
// Is last line used?
......@@ -96,14 +96,12 @@ namespace basegfx
}
// reset last line, it equals default
delete const_cast<ImplHomMatrixTemplate< RowSize >*>(this)->mpLine;
const_cast<ImplHomMatrixTemplate< RowSize >*>(this)->mpLine = nullptr;
mpLine.reset();
return true;
}
ImplHomMatrixTemplate()
: mpLine(nullptr)
{
// complete initialization with identity matrix, all lines
// were initialized with a trailing 1 followed by 0's.
......@@ -115,26 +113,22 @@ namespace basegfx
}
ImplHomMatrixTemplate(const ImplHomMatrixTemplate& rToBeCopied)
: mpLine(nullptr)
{
operator=(rToBeCopied);
}
ImplHomMatrixTemplate& operator=(const ImplHomMatrixTemplate& rToBeCopied)
{
// complete initialization using copy
for(sal_uInt16 a(0); a < (RowSize - 1); a++)
{
memcpy(&maLine[a], &rToBeCopied.maLine[a], sizeof(ImplMatLine< RowSize >));
}
if(rToBeCopied.mpLine)
{
mpLine = new ImplMatLine< RowSize >((RowSize - 1), rToBeCopied.mpLine);
}
}
~ImplHomMatrixTemplate()
{
if(mpLine)
{
delete mpLine;
mpLine.reset( new ImplMatLine< RowSize >((RowSize - 1), rToBeCopied.mpLine.get()) );
}
return *this;
}
static sal_uInt16 getEdgeLength() { return RowSize; }
......@@ -170,7 +164,7 @@ namespace basegfx
if(!::basegfx::fTools::equal(fDefault, rValue))
{
mpLine = new ImplMatLine< RowSize >((RowSize - 1), nullptr);
mpLine.reset(new ImplMatLine< RowSize >((RowSize - 1), nullptr));
mpLine->set(nColumn, rValue);
}
}
......@@ -195,8 +189,7 @@ namespace basegfx
if(!bNecessary)
{
delete mpLine;
mpLine = nullptr;
mpLine.reset();
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment