svx/source/sdr/contact/viewcontactofsdrpathobj.cxx |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

New commits:
commit bfe32f3e50b5406810e740ac41368f101033e766
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Jan 12 20:51:39 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Jan 13 07:36:48 2022 +0100

    optimise ensureGeometry
    
    for complex polygons, return early
    
    Change-Id: Id4bb2311f84508d95a71a3f4353872164baabe6e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128354
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx 
b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx
index fae763c28e1c..8798d40fb70b 100644
--- a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx
+++ b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx
@@ -43,7 +43,8 @@ namespace sdr::contact
         {
         }
 
-        static sal_uInt32 ensureGeometry(basegfx::B2DPolyPolygon& 
rUnitPolyPolygon)
+        /// return true if polycount == 1
+        static bool ensureGeometry(basegfx::B2DPolyPolygon& rUnitPolyPolygon)
         {
             sal_uInt32 nPolyCount(rUnitPolyPolygon.count());
             sal_uInt32 nPointCount(0);
@@ -51,6 +52,8 @@ namespace sdr::contact
             for(auto const& rPolygon : std::as_const(rUnitPolyPolygon))
             {
                 nPointCount += rPolygon.count();
+                if (nPointCount > 1)
+                    return false;
             }
 
             if(!nPointCount)
@@ -64,7 +67,7 @@ namespace sdr::contact
                 nPolyCount = 1;
             }
 
-            return nPolyCount;
+            return nPolyCount == 1;
         }
 
         void 
ViewContactOfSdrPathObj::createViewIndependentPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DDecompositionVisitor&
 rVisitor) const
@@ -76,14 +79,14 @@ namespace sdr::contact
                     GetPathObj().getText(0),
                     false));
             basegfx::B2DPolyPolygon 
aUnitPolyPolygon(GetPathObj().GetPathPoly());
-            sal_uInt32 nPolyCount(ensureGeometry(aUnitPolyPolygon));
+            bool bPolyCountIsOne(ensureGeometry(aUnitPolyPolygon));
 
             // prepare object transformation and unit polygon (direct model 
data)
             basegfx::B2DHomMatrix aObjectMatrix;
             basegfx::B2DPolyPolygon aUnitDefinitionPolyPolygon;
             bool bIsLine(
                 !aUnitPolyPolygon.areControlPointsUsed()
-                && 1 == nPolyCount
+                && bPolyCountIsOne
                 && 2 == aUnitPolyPolygon.getB2DPolygon(0).count());
 
             if(bIsLine)
@@ -113,12 +116,12 @@ namespace sdr::contact
 
                     aUnitPolyPolygon = 
basegfx::utils::clipPolyPolygonOnRange(aUnitPolyPolygon,
                                                                        
aClipRange, true, true);
-                    nPolyCount = ensureGeometry(aUnitPolyPolygon);
+                    bPolyCountIsOne = ensureGeometry(aUnitPolyPolygon);
 
                     // re-check that we have't been clipped out to oblivion
                     bIsLine =
                         !aUnitPolyPolygon.areControlPointsUsed()
-                        && 1 == nPolyCount
+                        && bPolyCountIsOne
                         && 2 == aUnitPolyPolygon.getB2DPolygon(0).count();
                 }
             }

Reply via email to