diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-06-28 12:28:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-06-28 14:37:51 +0200 |
commit | e8aea2a4f660cff901c56bcbd2a88377482f4609 (patch) | |
tree | 4fcf3c5f7c57e264122b0bd4e01da9d72704aa14 /vcl/source | |
parent | bdd217c1f23e0fb5f84542f1fb41036c3de538df (diff) |
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.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/gdi/region.cxx | 16 |
1 files changed, 10 insertions, 6 deletions
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; |