[Libreoffice-commits] core.git: filter/source oox/source sc/source sdext/source sw/qa sw/source vcl/inc vcl/source xmloff/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Jul 11 19:44:25 UTC 2017


 filter/source/msfilter/svdfppt.cxx                           |    2 +-
 oox/source/core/contexthandler2.cxx                          |    2 +-
 oox/source/docprop/ooxmldocpropimport.cxx                    |    2 +-
 oox/source/drawingml/table/tablecontext.cxx                  |    2 +-
 oox/source/drawingml/table/tablerowcontext.cxx               |    2 +-
 oox/source/drawingml/table/tablestylelistfragmenthandler.cxx |    2 +-
 oox/source/ole/vbainputstream.cxx                            |    2 +-
 sc/source/core/tool/interpr5.cxx                             |    2 +-
 sc/source/filter/excel/xeformula.cxx                         |    2 +-
 sc/source/filter/oox/autofilterbuffer.cxx                    |    6 +++---
 sc/source/filter/oox/formulabase.cxx                         |    2 +-
 sc/source/filter/oox/pivotcachebuffer.cxx                    |    2 +-
 sc/source/ui/unoobj/dapiuno.cxx                              |    2 +-
 sdext/source/presenter/PresenterAccessibility.cxx            |    2 +-
 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 ++--
 vcl/inc/opengl/RenderList.hxx                                |    2 +-
 vcl/source/gdi/pngwrite.cxx                                  |    2 +-
 xmloff/source/forms/propertyimport.cxx                       |    2 +-
 22 files changed, 28 insertions(+), 30 deletions(-)

New commits:
commit 05f47e6d9f0c442e481b2435cc5c2ef615ab347a
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jul 11 14:29:18 2017 +0200

    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 <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 1b290223458b..4325c0c92d8e 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -5201,7 +5201,7 @@ void PPTStyleTextPropReader::Init( SvStream& rIn, const DffRecordHeader& rTextHe
         auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, rExtParaHd.GetRecEndFilePos());
         while( ( rIn.GetError() == ERRCODE_NONE ) && ( rIn.Tell() < nEndRecPos ) )
         {
-            aStyleTextProp9.resize( aStyleTextProp9.size() + 1 );
+            aStyleTextProp9.emplace_back();
             aStyleTextProp9.back().Read( rIn );
         }
         rIn.Seek( nMerk );
diff --git a/oox/source/core/contexthandler2.cxx b/oox/source/core/contexthandler2.cxx
index 3d6aadf81484..50a2587e3e1f 100644
--- a/oox/source/core/contexthandler2.cxx
+++ b/oox/source/core/contexthandler2.cxx
@@ -144,7 +144,7 @@ void ContextHandler2Helper::implEndRecord( sal_Int32 nRecId )
 
 ElementInfo& ContextHandler2Helper::pushElementInfo( sal_Int32 nElement )
 {
-    mxContextStack->resize( mxContextStack->size() + 1 );
+    mxContextStack->emplace_back();
     ElementInfo& rInfo = mxContextStack->back();
     rInfo.mnElement = nElement;
     return rInfo;
diff --git a/oox/source/docprop/ooxmldocpropimport.cxx b/oox/source/docprop/ooxmldocpropimport.cxx
index 638c7a0aa978..8bd24bdc9e08 100644
--- a/oox/source/docprop/ooxmldocpropimport.cxx
+++ b/oox/source/docprop/ooxmldocpropimport.cxx
@@ -91,7 +91,7 @@ Sequence< InputSource > lclGetRelatedStreams( const Reference< XStorage >& rxSto
                 Reference< XInputStream > xInStream = xExtStream->getInputStream();
                 if( xInStream.is() )
                 {
-                    aResult.resize( aResult.size() + 1 );
+                    aResult.emplace_back();
                     aResult.back().sSystemId = rEntry.Second;
                     aResult.back().aInputStream = xExtStream->getInputStream();
                 }
diff --git a/oox/source/drawingml/table/tablecontext.cxx b/oox/source/drawingml/table/tablecontext.cxx
index 2cfe580f8abe..39b7d1fca161 100644
--- a/oox/source/drawingml/table/tablecontext.cxx
+++ b/oox/source/drawingml/table/tablecontext.cxx
@@ -77,7 +77,7 @@ TableContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList& r
     case A_TOKEN( tr ):                 // CT_TableRow
         {
             std::vector< TableRow >& rvTableRows( mrTableProperties.getTableRows() );
-            rvTableRows.resize( rvTableRows.size() + 1 );
+            rvTableRows.emplace_back();
             return new TableRowContext( *this, rAttribs, rvTableRows.back() );
         }
     }
diff --git a/oox/source/drawingml/table/tablerowcontext.cxx b/oox/source/drawingml/table/tablerowcontext.cxx
index d8f5bb4b65fe..afef21608ec1 100644
--- a/oox/source/drawingml/table/tablerowcontext.cxx
+++ b/oox/source/drawingml/table/tablerowcontext.cxx
@@ -49,7 +49,7 @@ TableRowContext::onCreateContext( ::sal_Int32 aElementToken, const AttributeList
     case A_TOKEN( tc ):         // CT_TableCell
         {
             std::vector< TableCell >& rvTableCells = mrTableRow.getTableCells();
-            rvTableCells.resize( rvTableCells.size() + 1 );
+            rvTableCells.emplace_back();
             return new TableCellContext( *this, rAttribs, rvTableCells.back() );
         }
     case A_TOKEN( extLst ):     // CT_OfficeArtExtensionList
diff --git a/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx b/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx
index b7c7afe10e84..2d5b60ff5a3a 100644
--- a/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx
+++ b/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx
@@ -54,7 +54,7 @@ ContextHandlerRef TableStyleListFragmentHandler::onCreateContext(
             break;
         case A_TOKEN( tblStyle ):       // CT_TableStyle
             std::vector< TableStyle >& rTableStyles = mrTableStyleList.getTableStyles();
-            rTableStyles.resize( rTableStyles.size() + 1 );
+            rTableStyles.emplace_back();
             return new TableStyleContext( *this, rAttribs, rTableStyles.back() );
     }
     return this;
diff --git a/oox/source/ole/vbainputstream.cxx b/oox/source/ole/vbainputstream.cxx
index 0e9262ceab04..76b5cd6b49f5 100644
--- a/oox/source/ole/vbainputstream.cxx
+++ b/oox/source/ole/vbainputstream.cxx
@@ -184,7 +184,7 @@ bool VbaInputStream::updateChunk()
                 // we suspect this will never be called
                 else
                 {
-                    maChunk.resize( maChunk.size() + 1 );
+                    maChunk.emplace_back();
                     maChunk.back() = mpInStrm->readuChar();
                     ++nChunkPos;
                 }
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index db8fd8605075..7aba82b116db 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -875,7 +875,7 @@ void ScInterpreter::ScModalValue_Multi()
                 {
                     if ( nCount > nMax )
                         nMax = nCount;
-                    aResultArray.resize( aResultArray.size() + 1 );
+                    aResultArray.emplace_back();
                 }
                 aResultArray[ aResultArray.size() -1  ] = nOldVal;
                 nCount = 1;
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index ccc2ce6218d4..2db8240b8d23 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -1900,7 +1900,7 @@ XclExpRefLogEntry* XclExpFmlaCompImpl::GetNewRefLogEntry()
 {
     if( mxData->mpRefLog )
     {
-        mxData->mpRefLog->resize( mxData->mpRefLog->size() + 1 );
+        mxData->mpRefLog->emplace_back();
         return &mxData->mpRefLog->back();
     }
     return nullptr;
diff --git a/sc/source/filter/oox/autofilterbuffer.cxx b/sc/source/filter/oox/autofilterbuffer.cxx
index 3b20a87c19a7..584822f63d0f 100644
--- a/sc/source/filter/oox/autofilterbuffer.cxx
+++ b/sc/source/filter/oox/autofilterbuffer.cxx
@@ -150,7 +150,7 @@ ApiFilterSettings::ApiFilterSettings()
 
 void ApiFilterSettings::appendField( bool bAnd, sal_Int32 nOperator, double fValue )
 {
-    maFilterFields.resize( maFilterFields.size() + 1 );
+    maFilterFields.emplace_back();
     TableFilterField3& rFilterField = maFilterFields.back();
     rFilterField.Connection = bAnd ? FilterConnection_AND : FilterConnection_OR;
     rFilterField.Operator = nOperator;
@@ -161,7 +161,7 @@ void ApiFilterSettings::appendField( bool bAnd, sal_Int32 nOperator, double fVal
 
 void ApiFilterSettings::appendField( bool bAnd, sal_Int32 nOperator, const OUString& rValue )
 {
-    maFilterFields.resize( maFilterFields.size() + 1 );
+    maFilterFields.emplace_back();
     TableFilterField3& rFilterField = maFilterFields.back();
     rFilterField.Connection = bAnd ? FilterConnection_AND : FilterConnection_OR;
     rFilterField.Operator = nOperator;
@@ -172,7 +172,7 @@ void ApiFilterSettings::appendField( bool bAnd, sal_Int32 nOperator, const OUStr
 
 void ApiFilterSettings::appendField( bool bAnd, const std::vector<OUString>& rValues )
 {
-    maFilterFields.resize( maFilterFields.size() + 1 );
+    maFilterFields.emplace_back();
     TableFilterField3& rFilterField = maFilterFields.back();
     rFilterField.Connection = bAnd ? FilterConnection_AND : FilterConnection_OR;
     rFilterField.Operator = FilterOperator2::EQUAL;
diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx
index a26dd6884af8..2d2b89eab980 100644
--- a/sc/source/filter/oox/formulabase.cxx
+++ b/sc/source/filter/oox/formulabase.cxx
@@ -127,7 +127,7 @@ ApiTokenVector::ApiTokenVector()
 
 Any& ApiTokenVector::append( sal_Int32 nOpCode )
 {
-    mvTokens.resize( mvTokens.size() + 1 );
+    mvTokens.emplace_back();
     mvTokens.back().OpCode = nOpCode;
     return mvTokens.back().Data;
 }
diff --git a/sc/source/filter/oox/pivotcachebuffer.cxx b/sc/source/filter/oox/pivotcachebuffer.cxx
index b0ef8509f9a2..25e75fd38f89 100644
--- a/sc/source/filter/oox/pivotcachebuffer.cxx
+++ b/sc/source/filter/oox/pivotcachebuffer.cxx
@@ -303,7 +303,7 @@ void PivotCacheItemList::getCacheItemNames( ::std::vector< OUString >& orItemNam
 
 PivotCacheItem& PivotCacheItemList::createItem()
 {
-    maItems.resize( maItems.size() + 1 );
+    maItems.emplace_back();
     return maItems.back();
 }
 
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 190f509a030e..d2a7f81d986d 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -2920,7 +2920,7 @@ void SAL_CALL ScDataPilotFieldGroupsObj::insertByName( const OUString& rName, co
         throw IllegalArgumentException("Invalid element object", static_cast<cppu::OWeakObject*>(this), 0);
 
     // create the new entry if no error has been occurred
-    maGroups.resize( maGroups.size() + 1 );
+    maGroups.emplace_back();
     ScFieldGroup& rGroup = maGroups.back();
     rGroup.maName = rName;
     rGroup.maMembers.swap( aMembers );
diff --git a/sdext/source/presenter/PresenterAccessibility.cxx b/sdext/source/presenter/PresenterAccessibility.cxx
index 849590cab476..a2764c1b7d2e 100644
--- a/sdext/source/presenter/PresenterAccessibility.cxx
+++ b/sdext/source/presenter/PresenterAccessibility.cxx
@@ -1290,7 +1290,7 @@ void AccessibleRelationSet::AddRelation (
     const sal_Int16 nRelationType,
     const Reference<XInterface>& rxObject)
 {
-    maRelations.resize(maRelations.size()+1);
+    maRelations.emplace_back();
     maRelations.back().RelationType = nRelationType;
     maRelations.back().TargetSet.realloc(1);
     maRelations.back().TargetSet[0] = rxObject;
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<beans::PropertyValue>& rFilterOptions)
     {
         OUString sPassword = OUString::createFromAscii(pPassword);
-        rFilterOptions.resize(rFilterOptions.size() + 1);
+        rFilterOptions.emplace_back();
         xInteractionHandler = rtl::Reference<TestInteractionHandler>(new TestInteractionHandler(sPassword));
         uno::Reference<task::XInteractionHandler2> 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<PropertyValue> 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);
diff --git a/vcl/inc/opengl/RenderList.hxx b/vcl/inc/opengl/RenderList.hxx
index 062971ec29f3..6188203c77ea 100644
--- a/vcl/inc/opengl/RenderList.hxx
+++ b/vcl/inc/opengl/RenderList.hxx
@@ -95,7 +95,7 @@ private:
     {
         if (maRenderEntries.empty() || doesOverlap(rDrawRectangle))
         {
-            maRenderEntries.resize(maRenderEntries.size() + 1);
+            maRenderEntries.emplace_back();
             maRenderEntries.back().maOverlapTrackingRectangle = rDrawRectangle;
 
             maRectangles.clear();
diff --git a/vcl/source/gdi/pngwrite.cxx b/vcl/source/gdi/pngwrite.cxx
index c3f07eb06538..ccc4b50d71e7 100644
--- a/vcl/source/gdi/pngwrite.cxx
+++ b/vcl/source/gdi/pngwrite.cxx
@@ -656,7 +656,7 @@ void PNGWriterImpl::ImplClearFirstScanline()
 
 void PNGWriterImpl::ImplOpenChunk (sal_uLong nChunkType)
 {
-    maChunkSeq.resize(maChunkSeq.size() + 1);
+    maChunkSeq.emplace_back();
     maChunkSeq.back().nType = nChunkType;
 }
 
diff --git a/xmloff/source/forms/propertyimport.cxx b/xmloff/source/forms/propertyimport.cxx
index 1d0b76784f07..43564dd8866c 100644
--- a/xmloff/source/forms/propertyimport.cxx
+++ b/xmloff/source/forms/propertyimport.cxx
@@ -530,7 +530,7 @@ SvXMLImportContext* OListPropertyContext::CreateChildContext( sal_uInt16 _nPrefi
 {
     if ( token::IsXMLToken( _rLocalName, token::XML_LIST_VALUE ) )
     {
-        m_aListValues.resize( m_aListValues.size() + 1 );
+        m_aListValues.emplace_back();
         return new OListValueContext( GetImport(), _nPrefix, _rLocalName, *m_aListValues.rbegin() );
     }
     else


More information about the Libreoffice-commits mailing list