diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-06-23 15:02:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-06-24 08:43:55 +0200 |
commit | a2fc883173d7053cefe543620982051ae40c4b03 (patch) | |
tree | dac1b760925c8151dfd8a9cbe3a8735b68ab9f79 /xmloff | |
parent | 010713e65ccade7b682c219707c8db3d864145c1 (diff) |
use more std::container::insert instead of std::copy
which is both more compact code, and more efficient, since the insert
method can do smarter resizing
Change-Id: I17f226660f87cdf002edccc29b4af8fd59a25f91
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96948
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/chart/SchXMLExport.cxx | 26 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLSeriesHelper.cxx | 3 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLTableContext.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/forms/elementimport.cxx | 14 | ||||
-rw-r--r-- | xmloff/source/style/xmlexppr.cxx | 3 |
5 files changed, 11 insertions, 41 deletions
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 12e97512e615..b38f4df2b84c 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -345,21 +345,6 @@ private: OUString m_aRole; }; -template< typename T > - void lcl_SequenceToVectorAppend( const Sequence< T > & rSource, ::std::vector< T > & rDestination ) -{ - rDestination.reserve( rDestination.size() + rSource.getLength()); - ::std::copy( rSource.begin(), rSource.end(), - ::std::back_inserter( rDestination )); -} - -template< typename T > - void lcl_SequenceToVector( const Sequence< T > & rSource, ::std::vector< T > & rDestination ) -{ - rDestination.clear(); - lcl_SequenceToVectorAppend( rSource, rDestination ); -} - Reference< chart2::data::XLabeledDataSequence > lcl_getCategories( const Reference< chart2::XDiagram > & xDiagram ) { Reference< chart2::data::XLabeledDataSequence > xResult; @@ -428,7 +413,7 @@ Sequence< Reference< chart2::data::XLabeledDataSequence > > lcl_getAllSeriesSequ if( !xDataSource.is() ) continue; uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() ); - lcl_SequenceToVectorAppend( aDataSequences, aContainer ); + aContainer.insert( aContainer.end(), aDataSequences.begin(), aDataSequences.end() ); } } @@ -678,8 +663,7 @@ uno::Sequence< OUString > lcl_DataSequenceToStringSequence( } } - ::std::copy( aValuesSequence.begin(), aValuesSequence.end(), - ::std::back_inserter( aResult )); + aResult.insert( aResult.end(), aValuesSequence.begin(), aValuesSequence.end() ); return aResult; } @@ -828,7 +812,8 @@ lcl_TableData lcl_getDataForLocalTable( tStringVector& rLabels = bSeriesFromColumns ? aResult.aColumnDescriptions : aResult.aRowDescriptions; //categories - lcl_SequenceToVector( aSimpleCategories, rCategories ); + rCategories.clear(); + rCategories.insert( rCategories.begin(), aSimpleCategories.begin(), aSimpleCategories.end() ); if( !rCategoriesRange.isEmpty() ) { OUString aRange(rCategoriesRange); @@ -3283,8 +3268,7 @@ void SchXMLExportHelper_Impl::exportDataPoints( if( bVaryColorsByPoint && xColorScheme.is() ) { ::std::set< sal_Int32 > aAttrPointSet; - ::std::copy( pPoints, pPoints + aDataPointSeq.getLength(), - ::std::inserter( aAttrPointSet, aAttrPointSet.begin())); + aAttrPointSet.insert( pPoints, pPoints + aDataPointSeq.getLength() ); const ::std::set< sal_Int32 >::const_iterator aEndIt( aAttrPointSet.end()); for( nElement = 0; nElement < nSeriesLength; ++nElement ) { diff --git a/xmloff/source/chart/SchXMLSeriesHelper.cxx b/xmloff/source/chart/SchXMLSeriesHelper.cxx index 00adebc0d347..380830b40fc6 100644 --- a/xmloff/source/chart/SchXMLSeriesHelper.cxx +++ b/xmloff/source/chart/SchXMLSeriesHelper.cxx @@ -53,8 +53,7 @@ using ::com::sun::star::uno::Sequence; { Reference< chart2::XDataSeriesContainer > xDSCnt( rChartType, uno::UNO_QUERY_THROW ); Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() ); - ::std::copy( aSeriesSeq.begin(), aSeriesSeq.end(), - ::std::back_inserter( aResult )); + aResult.insert( aResult.end(), aSeriesSeq.begin(), aSeriesSeq.end() ); } } } diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx index b561dcfb058e..d4a7b143590a 100644 --- a/xmloff/source/chart/SchXMLTableContext.cxx +++ b/xmloff/source/chart/SchXMLTableContext.cxx @@ -306,8 +306,7 @@ void SchXMLTableContext::EndElement() if( !bModified ) { SAL_WARN_IF( !aModifiedRow.empty(), "xmloff.chart", "aModifiedRow is NOT NULL"); - aModifiedRow.reserve( rRow.size()); - ::std::copy( rRow.begin(), rRow.end(), ::std::back_inserter( aModifiedRow )); + aModifiedRow.insert( aModifiedRow.end(), rRow.begin(), rRow.end() ); SAL_WARN_IF( aModifiedRow.empty(), "xmloff.chart", "aModifiedRow is NULL"); } SAL_WARN_IF( nDestinationIndex >= aModifiedRow.size(), "xmloff.chart", "nDestinationIndex >= aModifiedRow.size()"); @@ -343,8 +342,7 @@ void SchXMLTableContext::EndElement() if( !bModified ) { SAL_WARN_IF( !aDestination.empty(), "xmloff.chart", "aDestination is NOT NULL"); - aDestination.reserve( mrTable.aData.size()); - ::std::copy( mrTable.aData.begin(), mrTable.aData.end(), ::std::back_inserter( aDestination )); + aDestination.insert( aDestination.end(), mrTable.aData.begin(), mrTable.aData.end()); SAL_WARN_IF( aDestination.empty(), "xmloff.chart", "aDestination is NULL"); } SAL_WARN_IF( nDestinationIndex >= aDestination.size(), "xmloff.chart", "nDestinationIndex >= aDestination.size()"); diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 622d71018633..14178490f7b1 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -1388,12 +1388,7 @@ namespace xmloff OSL_ENSURE( aValuePropertyPos->Name == PROPERTY_TEXT, "OTextLikeImport::EndElement: text:p was present, but our value property is *not* 'Text'!" ); if ( aValuePropertyPos->Name == PROPERTY_TEXT ) { - ::std::copy( - aValuePropertyPos + 1, - m_aValues.end(), - aValuePropertyPos - ); - m_aValues.resize( m_aValues.size() - 1 ); + m_aValues.erase(aValuePropertyPos); } } @@ -1443,12 +1438,7 @@ namespace xmloff { // complete remove this property value from the array. Today's "default value" of the "DefaultControl" // property is sufficient - ::std::copy( - aDefaultControlPropertyPos + 1, - m_aValues.end(), - aDefaultControlPropertyPos - ); - m_aValues.resize( m_aValues.size() - 1 ); + m_aValues.erase(aDefaultControlPropertyPos); } } } diff --git a/xmloff/source/style/xmlexppr.cxx b/xmloff/source/style/xmlexppr.cxx index 7601bf1f12c6..133168967fb7 100644 --- a/xmloff/source/style/xmlexppr.cxx +++ b/xmloff/source/style/xmlexppr.cxx @@ -145,8 +145,7 @@ void XMLPropertyStates_Impl::FillPropertyStateVector( { if (nCount) { - rVector.resize(nCount, XMLPropertyState(-1)); - ::std::copy( aPropStates.begin(), aPropStates.end(), rVector.begin() ); + rVector.insert( rVector.begin(), aPropStates.begin(), aPropStates.end() ); } } |