[Libreoffice-commits] core.git: scaddins/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Oct 1 07:09:03 UTC 2018
scaddins/source/analysis/analysishelper.cxx | 14 ++++++--------
scaddins/source/analysis/analysishelper.hxx | 3 ++-
2 files changed, 8 insertions(+), 9 deletions(-)
New commits:
commit bb8207ed0a900e1e45c5d3f91f82d28d5c88bc43
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Sep 28 11:24:04 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Oct 1 09:08:41 2018 +0200
loplugin:useuniqueptr in scaddins::ConvertDataLinear
Change-Id: I071e7b072ea6b96a527ccbac91e122f0253eb448
Reviewed-on: https://gerrit.libreoffice.org/61117
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx
index 20bd97273fc3..a6b8e7df568c 100644
--- a/scaddins/source/analysis/analysishelper.cxx
+++ b/scaddins/source/analysis/analysishelper.cxx
@@ -2298,10 +2298,10 @@ double ConvertDataLinear::ConvertFromBase( double f, sal_Int16 n ) const
ConvertDataList::ConvertDataList()
{
-#define NEWD(str,unit,cl) maVector.push_back(new ConvertData(str,unit,cl))
-#define NEWDP(str,unit,cl) maVector.push_back(new ConvertData(str,unit,cl,true))
-#define NEWL(str,unit,offs,cl) maVector.push_back(new ConvertDataLinear(str,unit,offs,cl))
-#define NEWLP(str,unit,offs,cl) maVector.push_back(new ConvertDataLinear(str,unit,offs,cl,true))
+#define NEWD(str,unit,cl) maVector.emplace_back(new ConvertData(str,unit,cl))
+#define NEWDP(str,unit,cl) maVector.emplace_back(new ConvertData(str,unit,cl,true))
+#define NEWL(str,unit,offs,cl) maVector.emplace_back(new ConvertDataLinear(str,unit,offs,cl))
+#define NEWLP(str,unit,offs,cl) maVector.emplace_back(new ConvertDataLinear(str,unit,offs,cl,true))
// *** are extra and not standard Excel Analysis Addin!
@@ -2481,8 +2481,6 @@ ConvertDataList::ConvertDataList()
ConvertDataList::~ConvertDataList()
{
- for( std::vector<ConvertData*>::const_iterator it = maVector.begin(); it != maVector.end(); ++it )
- delete *it;
}
@@ -2495,10 +2493,10 @@ double ConvertDataList::Convert( double fVal, const OUString& rFrom, const OUStr
sal_Int16 nLevelFrom = 0;
sal_Int16 nLevelTo = 0;
- std::vector<ConvertData*>::iterator it = maVector.begin();
+ auto it = maVector.begin();
while( it != maVector.end() && ( bSearchFrom || bSearchTo ) )
{
- ConvertData* p = *it;
+ ConvertData* p = it->get();
if( bSearchFrom )
{
sal_Int16 n = p->GetMatchingLevel( rFrom );
diff --git a/scaddins/source/analysis/analysishelper.hxx b/scaddins/source/analysis/analysishelper.hxx
index 85dc1eb65ccb..f0eaac926dfb 100644
--- a/scaddins/source/analysis/analysishelper.hxx
+++ b/scaddins/source/analysis/analysishelper.hxx
@@ -34,6 +34,7 @@
#include "analysisdefs.hxx"
+#include <memory>
#include <vector>
@@ -576,7 +577,7 @@ public:
class ConvertDataList
{
private:
- std::vector<ConvertData*> maVector;
+ std::vector<std::unique_ptr<ConvertData>> maVector;
public:
ConvertDataList();
~ConvertDataList();
More information about the Libreoffice-commits
mailing list