diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-10-17 15:29:26 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-10-18 08:37:25 +0200 |
commit | 48a67502e657761b3c5f70adf732f4763fb8035a (patch) | |
tree | 6bcb7192e00a2ead84cf3c811d3d5e658c74acfb /scaddins | |
parent | 08f7502bf8a186a7b3d600c3543069ea544cabef (diff) |
use std::vector<Complex> in ComplexList
no need to use dynamic allocation here
Change-Id: I49192a8ba5e20891572e9ce3bc4dec51fafba0dc
Reviewed-on: https://gerrit.libreoffice.org/43474
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'scaddins')
-rw-r--r-- | scaddins/source/analysis/analysis.cxx | 8 | ||||
-rw-r--r-- | scaddins/source/analysis/analysishelper.cxx | 12 | ||||
-rw-r--r-- | scaddins/source/analysis/analysishelper.hxx | 12 |
3 files changed, 15 insertions, 17 deletions
diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx index c137d7ac2080..1f79f54cea7d 100644 --- a/scaddins/source/analysis/analysis.cxx +++ b/scaddins/source/analysis/analysis.cxx @@ -943,9 +943,9 @@ OUString SAL_CALL AnalysisAddIn::getImproduct( const uno::Reference< beans::XPro if( z_list.empty() ) return Complex( 0 ).GetString(); - Complex z( *(z_list.Get(0)) ); + Complex z = z_list.Get(0); for( sal_uInt32 i = 1; i < z_list.Count(); ++i ) - z.Mult( *(z_list.Get(i)) ); + z.Mult( z_list.Get(i) ); return z.GetString(); } @@ -984,9 +984,9 @@ OUString SAL_CALL AnalysisAddIn::getImsum( const uno::Reference< beans::XPropert if( z_list.empty() ) return Complex( 0 ).GetString(); - Complex z( *(z_list.Get(0)) ); + Complex z( z_list.Get(0) ); for( sal_uInt32 i = 1; i < z_list.Count(); ++i ) - z.Add( *(z_list.Get(i)) ); + z.Add( z_list.Get(i) ); return z.GetString(); } diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx index 19ea47cc5ef0..22328b2d2373 100644 --- a/scaddins/source/analysis/analysishelper.cxx +++ b/scaddins/source/analysis/analysishelper.cxx @@ -2031,8 +2031,6 @@ void Complex::Csch() ComplexList::~ComplexList() { - for(Complex* p : maVector) - delete p; } @@ -2054,9 +2052,9 @@ void ComplexList::Append( const uno::Sequence< uno::Sequence< OUString > >& r, C const OUString& rStr = rList[ n2 ]; if( !rStr.isEmpty() ) - Append( new Complex( rStr ) ); + Append( Complex( rStr ) ); else if( bEmpty0 ) - Append( new Complex( 0.0 ) ); + Append( Complex( 0.0 ) ); else if( bErrOnEmpty ) throw lang::IllegalArgumentException(); } @@ -2081,15 +2079,15 @@ void ComplexList::Append( const uno::Sequence< uno::Any >& aMultPars, ComplListA auto pStr = o3tl::forceAccess<OUString>(r); if( !pStr->isEmpty() ) - Append( new Complex( *pStr ) ); + Append( Complex( *pStr ) ); else if( bEmpty0 ) - Append( new Complex( 0.0 ) ); + Append( Complex( 0.0 ) ); else if( bErrOnEmpty ) throw lang::IllegalArgumentException(); } break; case uno::TypeClass_DOUBLE: - Append( new Complex( *o3tl::forceAccess<double>(r), 0.0 ) ); + Append( Complex( *o3tl::forceAccess<double>(r), 0.0 ) ); break; case uno::TypeClass_SEQUENCE: { diff --git a/scaddins/source/analysis/analysishelper.hxx b/scaddins/source/analysis/analysishelper.hxx index 591150aaaafa..280c4a396861 100644 --- a/scaddins/source/analysis/analysishelper.hxx +++ b/scaddins/source/analysis/analysishelper.hxx @@ -486,18 +486,18 @@ enum ComplListAppendHandl class ComplexList final { private: - std::vector<Complex*> maVector; + std::vector<Complex> maVector; public: ~ComplexList(); - inline const Complex* Get( sal_uInt32 nIndex ) const; + inline const Complex& Get( sal_uInt32 nIndex ) const; bool empty() const { return maVector.empty(); } sal_uInt32 Count() const { return maVector.size(); } - inline void Append( Complex* pNew ); + inline void Append( Complex&& pNew ); /// @throws css::uno::RuntimeException /// @throws css::lang::IllegalArgumentException void Append( const css::uno::Sequence< css::uno::Sequence< OUString > >& rComplexNumList, ComplListAppendHandl eAH ); @@ -723,15 +723,15 @@ inline void Complex::Add( const Complex& rAdd ) } -inline const Complex* ComplexList::Get( sal_uInt32 n ) const +inline const Complex& ComplexList::Get( sal_uInt32 n ) const { return maVector[n]; } -inline void ComplexList::Append( Complex* p ) +inline void ComplexList::Append( Complex&& p ) { - maVector.push_back(p); + maVector.emplace_back(p); } |