summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-06-28 12:30:22 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-06-28 15:24:58 +0200
commit7cc50e99381fe7a0d35d682c35ae44fbd003d3e7 (patch)
tree6e916fca25faa43485769c9d865bc987f481d5cd /vcl
parent120daca4198d8a4775bc5c7330a0c415213b7a0b (diff)
tdf#134328 only copy the RegionBand if it is actually shared
Change-Id: I870ac06dba2f41b5c005b8957049d64ff4a2d4e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136569 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/region.cxx13
1 files changed, 5 insertions, 8 deletions
diff --git a/vcl/source/gdi/region.cxx b/vcl/source/gdi/region.cxx
index ea03d8a0787c..78a862225ed2 100644
--- a/vcl/source/gdi/region.cxx
+++ b/vcl/source/gdi/region.cxx
@@ -725,15 +725,16 @@ void vcl::Region::Exclude( const tools::Rectangle& rRect )
}
// only region band mode possibility left here or null/empty
- const RegionBand* pCurrent = getRegionBand();
-
- if(!pCurrent)
+ if(!mpRegionBand)
{
// empty? -> done!
return;
}
- std::shared_ptr<RegionBand> pNew( std::make_shared<RegionBand>(*pCurrent));
+ std::shared_ptr<RegionBand>& pNew = mpRegionBand;
+ // only make a copy if someone else is also using it
+ if (pNew.use_count() > 1)
+ pNew = std::make_shared<RegionBand>(*pNew);
// get justified rectangle
const tools::Long nLeft(std::min(rRect.Left(), rRect.Right()));
@@ -749,11 +750,7 @@ void vcl::Region::Exclude( const tools::Rectangle& rRect )
// cleanup
if(!pNew->OptimizeBandList())
- {
pNew.reset();
- }
-
- mpRegionBand = std::move(pNew);
}
void vcl::Region::XOr( const tools::Rectangle& rRect )