[Libreoffice-commits] core.git: basegfx/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Aug 3 07:01:07 UTC 2018
basegfx/source/inc/hommatrixtemplate.hxx | 29 +++++++++++------------------
1 file changed, 11 insertions(+), 18 deletions(-)
New commits:
commit 1da9761c72e0893ee01abacb341435a1539a1f93
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Aug 2 12:44:49 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Aug 3 09:00:42 2018 +0200
loplugin:useuniqueptr in ImplHomMatrixTemplate
Change-Id: I31175a5110672e864b07d6b5508b8b04b14e66ee
Reviewed-on: https://gerrit.libreoffice.org/58484
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/basegfx/source/inc/hommatrixtemplate.hxx b/basegfx/source/inc/hommatrixtemplate.hxx
index 4e00fdf2119c..b7106f6fb22d 100644
--- a/basegfx/source/inc/hommatrixtemplate.hxx
+++ b/basegfx/source/inc/hommatrixtemplate.hxx
@@ -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();
}
}
}
More information about the Libreoffice-commits
mailing list