[Libreoffice-commits] core.git: 3 commits - basegfx/source basegfx/test comphelper/source compilerplugins/clang sfx2/source svx/source vcl/headless vcl/source vcl/unx

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 18 06:55:49 UTC 2021


 basegfx/source/polygon/b2dtrapezoid.cxx             |    6 +++---
 basegfx/test/boxclipper.cxx                         |    2 +-
 comphelper/source/processfactory/processfactory.cxx |    3 ++-
 compilerplugins/clang/sequenceloop.cxx              |    5 ++++-
 sfx2/source/appl/appopen.cxx                        |    2 --
 svx/source/sdr/contact/viewcontactofsdrpathobj.cxx  |    2 +-
 svx/source/svdraw/svdotextpathdecomposition.cxx     |    2 +-
 vcl/headless/svpgdi.cxx                             |    2 +-
 vcl/source/filter/wmf/emfwr.cxx                     |    4 ++--
 vcl/source/filter/wmf/wmfwr.cxx                     |    4 ++--
 vcl/source/gdi/FileDefinitionWidgetDraw.cxx         |    2 +-
 vcl/source/gdi/lineinfo.cxx                         |    4 ++--
 vcl/source/outdev/line.cxx                          |    8 ++++----
 vcl/source/outdev/polygon.cxx                       |    4 ++--
 vcl/source/outdev/transparent.cxx                   |    4 ++--
 vcl/unx/generic/gdi/salgdi.cxx                      |    2 +-
 16 files changed, 29 insertions(+), 27 deletions(-)

New commits:
commit f29ef71073bb31f05d6cc50f952e827134868c2d
Author:     Noel Grandin <noel at peralex.com>
AuthorDate: Tue Aug 17 14:46:29 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 18 08:55:23 2021 +0200

    avoid constructing OUString on hot path (tdf#105575)
    
    Change-Id: I7c9925fc7f68cdc9bd1a9c1834daabff09c8cf6e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120604
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/comphelper/source/processfactory/processfactory.cxx b/comphelper/source/processfactory/processfactory.cxx
index 8df1e244ca19..ea5595646e4c 100644
--- a/comphelper/source/processfactory/processfactory.cxx
+++ b/comphelper/source/processfactory/processfactory.cxx
@@ -86,8 +86,9 @@ Reference< XComponentContext > getComponentContext(
     Reference< XComponentContext > xRet;
     uno::Reference<beans::XPropertySet> const xProps( factory, uno::UNO_QUERY );
     if (xProps.is()) {
+        static constexpr OUStringLiteral DEFAULT_CONTEXT = u"DefaultContext";
         try {
-            xRet.set( xProps->getPropertyValue("DefaultContext"),
+            xRet.set( xProps->getPropertyValue(DEFAULT_CONTEXT),
                       uno::UNO_QUERY );
         }
         catch (beans::UnknownPropertyException & e) {
commit cc9bc379de14a5ecfcb7b510fe74beeab768f875
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Tue Aug 17 20:14:27 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 18 08:54:56 2021 +0200

    remove dead code
    
    ever since
        commit fd069bee7e57ad529c3c0974559fd2d84ec3151a
        Date:   Mon Sep 18 16:07:07 2000 +0000
        initial import
    
    Change-Id: I1fd724f2e4f31353da60d2615e6c840bbb88dfcb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120619
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index 15c47a31c0e5..5936accbfedb 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -504,8 +504,6 @@ void SfxApplication::NewDocExec_Impl( SfxRequest& rReq )
     }
 
     ErrCode lErr = ERRCODE_NONE;
-    SfxItemSet* pSet = new SfxAllItemSet( GetPool() );
-    pSet->Put( SfxBoolItem( SID_TEMPLATE, true ) );
     if ( !bDirect )
     {
         SfxDocumentTemplates aTmpFac;
commit f46740abc225f5b4c7f604bf3ef32c503c7fc858
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Aug 17 20:16:33 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 18 08:54:36 2021 +0200

    loplugin:sequenceloop also check for B2DPolyPolygon
    
    which has the same problem
    
    Change-Id: I98f9924626f26739e91d6a9d21e4276473ea314d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120620
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/basegfx/source/polygon/b2dtrapezoid.cxx b/basegfx/source/polygon/b2dtrapezoid.cxx
index f30001f52d2a..3a255c18a7a3 100644
--- a/basegfx/source/polygon/b2dtrapezoid.cxx
+++ b/basegfx/source/polygon/b2dtrapezoid.cxx
@@ -496,7 +496,7 @@ namespace basegfx::trapezoidhelper
                     aSource = aSource.getDefaultAdaptiveSubdivision();
                 }
 
-                for(const auto& aPolygonCandidate : aSource)
+                for(const auto& aPolygonCandidate : std::as_const(aSource))
                 {
                     // 1st run: count points
                     const sal_uInt32 nCount(aPolygonCandidate.count());
@@ -513,7 +513,7 @@ namespace basegfx::trapezoidhelper
                     // after 2nd loop since pointers to it are used in the edges
                     maPoints.reserve(nAllPointCount);
 
-                    for(const auto& aPolygonCandidate : aSource)
+                    for(const auto& aPolygonCandidate : std::as_const(aSource))
                     {
                         // 2nd run: add points
                         const sal_uInt32 nCount(aPolygonCandidate.count());
@@ -533,7 +533,7 @@ namespace basegfx::trapezoidhelper
                     // in the edges may be wrong. Security first here.
                     sal_uInt32 nStartIndex(0);
 
-                    for(const auto& aPolygonCandidate : aSource)
+                    for(const auto& aPolygonCandidate : std::as_const(aSource))
                     {
                         const sal_uInt32 nCount(aPolygonCandidate.count());
 
diff --git a/basegfx/test/boxclipper.cxx b/basegfx/test/boxclipper.cxx
index 8aaa45be9fbc..b65f25bae425 100644
--- a/basegfx/test/boxclipper.cxx
+++ b/basegfx/test/boxclipper.cxx
@@ -158,7 +158,7 @@ public:
         static constexpr OUStringLiteral randomSvg=u"m394 783h404v57h-404zm-197-505h571v576h-571zm356-634h75v200h-75zm-40-113h403v588h-403zm93-811h111v494h-111zm-364-619h562v121h-562zm-134-8h292v27h-292zm110 356h621v486h-621zm78-386h228v25h-228zm475-345h201v201h-201zm-2-93h122v126h-122zm-417-243h567v524h-567zm-266-738h863v456h-863zm262-333h315v698h-315zm-328-826h43v393h-43zm830-219h120v664h-120zm-311-636h221v109h-221zm-500 137h628v19h-628zm681-94h211v493h-211zm-366-646h384v355h-384zm-189-199h715v247h-715zm165-459h563v601h-563zm258-479h98v606h-98zm270-517h65v218h-65zm-44-259h96v286h-96zm-599-202h705v468h-705zm216-803h450v494h-450zm-150-22h26v167h-26zm-55-599h50v260h-50zm190-278h490v387h-490zm-290-453h634v392h-634zm257 189h552v300h-552zm-151-690h136v455h-136zm12-597h488v432h-488zm501-459h48v39h-48zm-224-112h429v22h-429zm-281 102h492v621h-492zm519-158h208v17h-208zm-681-563h56v427h-56zm126-451h615v392h-615zm-47-410h598v522h-598zm-32 316h79v110h-79zm-71-129h18v127h-18zm126-993h743v589h-7
 43zm211-430h428v750h-428zm61-554h100v220h-100zm-353-49h658v157h-658zm778-383h115v272h-115zm-249-541h119v712h-119zm203 86h94v40h-94z";
         B2DPolyPolygon randomPoly;
         CPPUNIT_ASSERT(utils::importFromSvgD(randomPoly, randomSvg, false, nullptr));
-        for (auto const& aPolygon : randomPoly)
+        for (auto const& aPolygon : std::as_const(randomPoly))
             aRandomIntersections.appendElement(aPolygon.getB2DRange(), B2VectorOrientation::Negative);
 #endif
     }
diff --git a/compilerplugins/clang/sequenceloop.cxx b/compilerplugins/clang/sequenceloop.cxx
index 7f14d6c4d951..8c931d70d5d1 100644
--- a/compilerplugins/clang/sequenceloop.cxx
+++ b/compilerplugins/clang/sequenceloop.cxx
@@ -56,7 +56,10 @@ bool SequenceLoop::VisitCXXForRangeStmt(CXXForRangeStmt const* forStmt)
              .Namespace("star")
              .Namespace("sun")
              .Namespace("com")
-             .GlobalNamespace())
+             .GlobalNamespace()
+        // B2DPolyPolygon is similar in that accessing the non-const begin()/end() methods
+        // might trigger unnecessary copying
+        && !tc.Class("B2DPolyPolygon").Namespace("basegfx").GlobalNamespace())
         return true;
     const VarDecl* varDecl = forStmt->getLoopVariable();
     auto tc2 = loplugin::TypeCheck(varDecl->getType());
diff --git a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx
index 00e3f1054bd9..7786c875bbde 100644
--- a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx
+++ b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx
@@ -46,7 +46,7 @@ namespace sdr::contact
             sal_uInt32 nPolyCount(rUnitPolyPolygon.count());
             sal_uInt32 nPointCount(0);
 
-            for(auto const& rPolygon : rUnitPolyPolygon)
+            for(auto const& rPolygon : std::as_const(rUnitPolyPolygon))
             {
                 nPointCount += rPolygon.count();
             }
diff --git a/svx/source/svdraw/svdotextpathdecomposition.cxx b/svx/source/svdraw/svdotextpathdecomposition.cxx
index 44f72ec8de07..d97d9129124b 100644
--- a/svx/source/svdraw/svdotextpathdecomposition.cxx
+++ b/svx/source/svdraw/svdotextpathdecomposition.cxx
@@ -557,7 +557,7 @@ namespace
             basegfx::B2DPolyPolygon aB2DPolyPolygon = rB2DPolyPolygon;
             aB2DPolyPolygon.transform(rTransform);
 
-            for(auto const& rPolygon : aB2DPolyPolygon)
+            for(auto const& rPolygon : std::as_const(aB2DPolyPolygon))
             {
                 // create one primitive per polygon
                 rTarget.push_back(
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index c756c79ae60a..926ef9fe1f6d 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -1942,7 +1942,7 @@ bool SvpSalGraphics::drawGradient(const tools::PolyPolygon& rPolyPolygon, const
     else
     {
         basegfx::B2DPolyPolygon aB2DPolyPolygon(rPolyPolygon.getB2DPolyPolygon());
-        for (auto const & rPolygon : aB2DPolyPolygon)
+        for (auto const & rPolygon : std::as_const(aB2DPolyPolygon))
         {
             basegfx::B2DHomMatrix rObjectToDevice;
             AddPolygonToPath(cr, rPolygon, rObjectToDevice, !getAntiAlias(), false);
diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx
index 6c6428959652..8c7f90654a14 100644
--- a/vcl/source/filter/wmf/emfwr.cxx
+++ b/vcl/source/filter/wmf/emfwr.cxx
@@ -950,7 +950,7 @@ void EMFWriter::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const bas
 
     if(aLinePolyPolygon.count())
     {
-        for(auto const& rB2DPolygon : aLinePolyPolygon)
+        for(auto const& rB2DPolygon : std::as_const(aLinePolyPolygon))
         {
             ImplWritePolygonRecord( tools::Polygon(rB2DPolygon), false );
         }
@@ -965,7 +965,7 @@ void EMFWriter::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const bas
     maVDev->SetLineColor();
     maVDev->SetFillColor(aOldLineColor);
 
-    for(auto const& rB2DPolygon : aFillPolyPolygon)
+    for(auto const& rB2DPolygon : std::as_const(aFillPolyPolygon))
     {
         ImplWritePolyPolygonRecord(tools::PolyPolygon( tools::Polygon(rB2DPolygon) ));
     }
diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx
index 90e51a4ca93b..ae62d54866d3 100644
--- a/vcl/source/filter/wmf/wmfwr.cxx
+++ b/vcl/source/filter/wmf/wmfwr.cxx
@@ -984,7 +984,7 @@ void WMFWriter::HandleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx:
         aSrcLineInfo = rInfo;
         SetLineAndFillAttr();
 
-        for(auto const& rB2DPolygon : aLinePolyPolygon)
+        for(auto const& rB2DPolygon : std::as_const(aLinePolyPolygon))
         {
             WMFRecord_PolyLine( tools::Polygon(rB2DPolygon) );
         }
@@ -1000,7 +1000,7 @@ void WMFWriter::HandleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx:
     aSrcFillColor = aOldLineColor;
     SetLineAndFillAttr();
 
-    for(auto const& rB2DPolygon : aFillPolyPolygon)
+    for(auto const& rB2DPolygon : std::as_const(aFillPolyPolygon))
     {
         WMFRecord_Polygon( tools::Polygon(rB2DPolygon) );
     }
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index 4a8f8bd8d953..ec840c984d80 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -384,7 +384,7 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics
                 {
                     rGraphics.SetLineColor(Color(*rPath.mpStrokeColor));
                     rGraphics.SetFillColor();
-                    for (auto const& rPolygon : aPolyPolygon)
+                    for (auto const& rPolygon : std::as_const(aPolyPolygon))
                     {
                         FileDefinitionWidgetDraw::drawPolyLine(
                             rGraphics, basegfx::B2DHomMatrix(), rPolygon, 1.0 - rPath.mnOpacity,
diff --git a/vcl/source/gdi/lineinfo.cxx b/vcl/source/gdi/lineinfo.cxx
index 345eeb21a678..27f4e408f95f 100644
--- a/vcl/source/gdi/lineinfo.cxx
+++ b/vcl/source/gdi/lineinfo.cxx
@@ -238,7 +238,7 @@ void LineInfo::applyToB2DPolyPolygon(
         {
             basegfx::B2DPolyPolygon aResult;
 
-            for(auto const& rPolygon : io_rLinePolyPolygon)
+            for(auto const& rPolygon : std::as_const(io_rLinePolyPolygon))
             {
                 basegfx::B2DPolyPolygon aLineTarget;
                 basegfx::utils::applyLineDashing(
@@ -257,7 +257,7 @@ void LineInfo::applyToB2DPolyPolygon(
 
     const double fHalfLineWidth((GetWidth() * 0.5) + 0.5);
 
-    for(auto const& rPolygon : io_rLinePolyPolygon)
+    for(auto const& rPolygon : std::as_const(io_rLinePolyPolygon))
     {
         o_rFillPolyPolygon.append(basegfx::utils::createAreaGeometry(
             rPolygon,
diff --git a/vcl/source/outdev/line.cxx b/vcl/source/outdev/line.cxx
index e7e84b58ad54..479705082265 100644
--- a/vcl/source/outdev/line.cxx
+++ b/vcl/source/outdev/line.cxx
@@ -184,7 +184,7 @@ void OutputDevice::drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const Lin
         {
             basegfx::B2DPolyPolygon aResult;
 
-            for(auto const& rPolygon : aLinePolyPolygon)
+            for(auto const& rPolygon : std::as_const(aLinePolyPolygon))
             {
                 basegfx::B2DPolyPolygon aLineTarget;
                 basegfx::utils::applyLineDashing(
@@ -212,7 +212,7 @@ void OutputDevice::drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const Lin
             aLinePolyPolygon = basegfx::utils::adaptiveSubdivideByDistance(aLinePolyPolygon, 1.0);
         }
 
-        for(auto const& rPolygon : aLinePolyPolygon)
+        for(auto const& rPolygon : std::as_const(aLinePolyPolygon))
         {
             aFillPolyPolygon.append(basegfx::utils::createAreaGeometry(
                 rPolygon,
@@ -229,7 +229,7 @@ void OutputDevice::drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const Lin
 
     if(aLinePolyPolygon.count())
     {
-        for(auto const& rB2DPolygon : aLinePolyPolygon)
+        for(auto const& rB2DPolygon : std::as_const(aLinePolyPolygon))
         {
             const bool bPixelSnapHairline(mnAntialiasing & AntialiasingFlags::PixelSnapHairline);
             bool bDone(false);
@@ -283,7 +283,7 @@ void OutputDevice::drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const Lin
 
         if(!bDone)
         {
-            for(auto const& rB2DPolygon : aFillPolyPolygon)
+            for(auto const& rB2DPolygon : std::as_const(aFillPolyPolygon))
             {
                 tools::Polygon aPolygon(rB2DPolygon);
 
diff --git a/vcl/source/outdev/polygon.cxx b/vcl/source/outdev/polygon.cxx
index e59ec9630690..772c2dbdea07 100644
--- a/vcl/source/outdev/polygon.cxx
+++ b/vcl/source/outdev/polygon.cxx
@@ -90,7 +90,7 @@ void OutputDevice::DrawPolyPolygon( const tools::PolyPolygon& rPolyPoly )
         {
             const bool bPixelSnapHairline(mnAntialiasing & AntialiasingFlags::PixelSnapHairline);
 
-            for(auto const& rPolygon : aB2DPolyPolygon)
+            for(auto const& rPolygon : std::as_const(aB2DPolyPolygon))
             {
                 bSuccess = mpGraphics->DrawPolyLine(
                     aTransform,
@@ -320,7 +320,7 @@ void OutputDevice::ImplDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyP
         {
             const bool bPixelSnapHairline(mnAntialiasing & AntialiasingFlags::PixelSnapHairline);
 
-            for(auto const& rPolygon : aB2DPolyPolygon)
+            for(auto const& rPolygon : std::as_const(aB2DPolyPolygon))
             {
                 bSuccess = mpGraphics->DrawPolyLine(
                     aTransform,
diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx
index 28e70a6f0f49..1648745d41e0 100644
--- a/vcl/source/outdev/transparent.cxx
+++ b/vcl/source/outdev/transparent.cxx
@@ -172,7 +172,7 @@ void OutputDevice::DrawTransparent(
         {
             const bool bPixelSnapHairline(mnAntialiasing & AntialiasingFlags::PixelSnapHairline);
 
-            for(auto const& rPolygon : aB2DPolyPolygon)
+            for(auto const& rPolygon : std::as_const(aB2DPolyPolygon))
             {
                 mpGraphics->DrawPolyLine(
                     aFullTransform,
@@ -293,7 +293,7 @@ bool OutputDevice::DrawTransparentNatively ( const tools::PolyPolygon& rPolyPoly
             // draw the border line
             const bool bPixelSnapHairline(mnAntialiasing & AntialiasingFlags::PixelSnapHairline);
 
-            for(auto const& rPolygon : aB2DPolyPolygon)
+            for(auto const& rPolygon : std::as_const(aB2DPolyPolygon))
             {
                 bDrawn = mpGraphics->DrawPolyLine(
                     aTransform,
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 544882fe6dc4..e809923fb3bd 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -613,7 +613,7 @@ bool X11SalGraphics::drawPolyPolygon(
         cairo_t* cr = getCairoContext();
         clipRegion(cr);
 
-        for(auto const& rPolygon : aPolyPolygon)
+        for(auto const& rPolygon : std::as_const(aPolyPolygon))
         {
             const sal_uInt32 nPointCount(rPolygon.count());
 


More information about the Libreoffice-commits mailing list