From 05f47e6d9f0c442e481b2435cc5c2ef615ab347a Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 11 Jul 2017 14:29:18 +0200 Subject: replace 'resize(size+1)' with emplace_back which is considerably faster if we're dealing with a std::list, and just easier on the eyes if we're dealing with a std::vector Change-Id: I373689205ebc048689f29ab80a7ee8551b20cc96 Reviewed-on: https://gerrit.libreoffice.org/39816 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/qa/extras/inc/swmodeltestbase.hxx | 2 +- sw/source/core/access/accpara.cxx | 6 +++--- sw/source/core/layout/paintfrm.cxx | 3 +-- sw/source/uibase/docvw/HeaderFooterWin.cxx | 5 ++--- sw/source/uibase/docvw/PageBreakWin.cxx | 4 ++-- 5 files changed, 9 insertions(+), 11 deletions(-) (limited to 'sw') diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index 75604978ceb4..7f258ab1baf7 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -622,7 +622,7 @@ protected: void setTestInteractionHandler(const char* pPassword, std::vector& rFilterOptions) { OUString sPassword = OUString::createFromAscii(pPassword); - rFilterOptions.resize(rFilterOptions.size() + 1); + rFilterOptions.emplace_back(); xInteractionHandler = rtl::Reference(new TestInteractionHandler(sPassword)); uno::Reference const xInteraction(xInteractionHandler.get()); rFilterOptions[0].Name = "InteractionHandler"; diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 3721a83df8a3..3bba2d24c3a6 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -1628,13 +1628,13 @@ uno::Sequence SwAccessibleParagraph::getCharacterAttributes( _correctValues( nIndex, aValues ); - aValues.resize( aValues.size() + 1 ); + aValues.emplace_back(); OUString strTypeName = GetFieldTypeNameAtIndex(nIndex); if (!strTypeName.isEmpty()) { - aValues.resize( aValues.size() + 1 ); - PropertyValue& rValueFT = aValues[aValues.size() - 1]; + aValues.emplace_back(); + PropertyValue& rValueFT = aValues.back(); rValueFT.Name = "FieldType"; rValueFT.Value <<= strTypeName.toAsciiLowerCase(); rValueFT.Handle = -1; diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 7d9e1d4c8df8..c0ddb50d4ad1 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -3832,7 +3832,6 @@ void SwColumnFrame::PaintBreak( ) const drawinglayer::primitive2d::Primitive2DContainer aSeq = lcl_CreateDashedIndicatorPrimitive( aStart, aEnd, aLineColor ); - aSeq.resize( aSeq.size( ) + 1 ); // Add the text above OUString aBreakText = SwResId(STR_COLUMN_BREAK); @@ -3867,7 +3866,7 @@ void SwColumnFrame::PaintBreak( ) const aFontAttr, lang::Locale(), aLineColor ); - aSeq[ aSeq.size() - 1 ] = drawinglayer::primitive2d::Primitive2DReference( pText ); + aSeq.push_back( drawinglayer::primitive2d::Primitive2DReference( pText ) ); ProcessPrimitives( aSeq ); } diff --git a/sw/source/uibase/docvw/HeaderFooterWin.cxx b/sw/source/uibase/docvw/HeaderFooterWin.cxx index ca5c7857d96c..9d567d207236 100644 --- a/sw/source/uibase/docvw/HeaderFooterWin.cxx +++ b/sw/source/uibase/docvw/HeaderFooterWin.cxx @@ -351,10 +351,9 @@ void SwHeaderFooterWin::Paint(vcl::RenderContext& rRenderContext, const ::tools: if (Application::GetSettings().GetStyleSettings().GetHighContrastMode()) aSignColor = Color(COL_WHITE).getBColor(); - aSeq.resize(aSeq.size() + 1); - aSeq[aSeq.size() - 1] = drawinglayer::primitive2d::Primitive2DReference( + aSeq.push_back( drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( - B2DPolyPolygon(aSign), aSignColor)); + B2DPolyPolygon(aSign), aSignColor)) ); // Create the processor and process the primitives const drawinglayer::geometry::ViewInformation2D aNewViewInfos; diff --git a/sw/source/uibase/docvw/PageBreakWin.cxx b/sw/source/uibase/docvw/PageBreakWin.cxx index 5615b3f8cd9f..fa1c78afe3af 100644 --- a/sw/source/uibase/docvw/PageBreakWin.cxx +++ b/sw/source/uibase/docvw/PageBreakWin.cxx @@ -196,8 +196,8 @@ void SwPageBreakWin::Paint(vcl::RenderContext& rRenderContext, const ::tools::Re if (Application::GetSettings().GetStyleSettings().GetHighContrastMode()) aTriangleColor = Color(COL_WHITE).getBColor(); - aSeq.resize(aSeq.size() + 1); - aSeq[aSeq.size() - 1].set( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( + aSeq.emplace_back(); + aSeq.back().set( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( B2DPolyPolygon(aTriangle), aTriangleColor)); drawinglayer::primitive2d::Primitive2DContainer aGhostedSeq(1); -- cgit