vcl/source/gdi/region.cxx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
New commits: commit e8aea2a4f660cff901c56bcbd2a88377482f4609 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Jun 28 12:28:49 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jun 28 14:37:51 2022 +0200 tdf#134328 use more make_shared one less allocation this way Change-Id: Id5fbd414837d7521306dd188306c4e60394307e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136566 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/vcl/source/gdi/region.cxx b/vcl/source/gdi/region.cxx index 576ae0eb2e10..ea03d8a0787c 100644 --- a/vcl/source/gdi/region.cxx +++ b/vcl/source/gdi/region.cxx @@ -316,7 +316,8 @@ Region::Region(bool bIsNull) Region::Region(const tools::Rectangle& rRect) : mbIsNull(false) { - mpRegionBand.reset(rRect.IsEmpty() ? nullptr : new RegionBand(rRect)); + if (!rRect.IsEmpty()) + mpRegionBand = std::make_shared<RegionBand>(rRect); } Region::Region(const tools::Polygon& rPolygon) @@ -437,12 +438,12 @@ void vcl::Region::Move( tools::Long nHorzMove, tools::Long nVertMove ) } else if(getRegionBand()) { - RegionBand* pNew = new RegionBand(*getRegionBand()); + std::shared_ptr<RegionBand> pNew = std::make_shared<RegionBand>(*getRegionBand()); pNew->Move(nHorzMove, nVertMove); mpB2DPolyPolygon.reset(); mpPolyPolygon.reset(); - mpRegionBand.reset(pNew); + mpRegionBand = std::move(pNew); } else { @@ -490,12 +491,12 @@ void vcl::Region::Scale( double fScaleX, double fScaleY ) } else if(getRegionBand()) { - RegionBand* pNew = new RegionBand(*getRegionBand()); + std::shared_ptr<RegionBand> pNew = std::make_shared<RegionBand>(*getRegionBand()); pNew->Scale(fScaleX, fScaleY); mpB2DPolyPolygon.reset(); mpPolyPolygon.reset(); - mpRegionBand.reset(pNew); + mpRegionBand = std::move(pNew); } else { @@ -1447,7 +1448,10 @@ Region& vcl::Region::operator=( const tools::Rectangle& rRect ) { mpB2DPolyPolygon.reset(); mpPolyPolygon.reset(); - mpRegionBand.reset(rRect.IsEmpty() ? nullptr : new RegionBand(rRect)); + if (!rRect.IsEmpty()) + mpRegionBand = std::make_shared<RegionBand>(rRect); + else + mpRegionBand.reset(); mbIsNull = false; return *this;