From a2fc883173d7053cefe543620982051ae40c4b03 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 23 Jun 2020 15:02:35 +0200 Subject: 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 --- chart2/source/tools/DataSeriesHelper.cxx | 3 +-- chart2/source/tools/DataSourceHelper.cxx | 6 ++---- chart2/source/tools/DiagramHelper.cxx | 6 ++---- chart2/source/tools/ImplOPropertySet.cxx | 3 +-- chart2/source/tools/InternalDataProvider.cxx | 4 +--- 5 files changed, 7 insertions(+), 15 deletions(-) (limited to 'chart2/source/tools') diff --git a/chart2/source/tools/DataSeriesHelper.cxx b/chart2/source/tools/DataSeriesHelper.cxx index c90a356bf2ee..11f6bf2d94b3 100644 --- a/chart2/source/tools/DataSeriesHelper.cxx +++ b/chart2/source/tools/DataSeriesHelper.cxx @@ -244,8 +244,7 @@ getAllDataSequences( const uno::Sequence >& if( xSource.is()) { Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( xSource->getDataSequences()); - std::copy( aSeq.begin(), aSeq.end(), - std::back_inserter( aSeqVec )); + aSeqVec.insert( aSeqVec.end(), aSeq.begin(), aSeq.end() ); } } diff --git a/chart2/source/tools/DataSourceHelper.cxx b/chart2/source/tools/DataSourceHelper.cxx index 50fd37347f09..cb74e60eaa54 100644 --- a/chart2/source/tools/DataSourceHelper.cxx +++ b/chart2/source/tools/DataSourceHelper.cxx @@ -310,8 +310,7 @@ uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData( if( !xDataSource.is() ) continue; uno::Sequence< uno::Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() ); - std::copy( aDataSequences.begin(), aDataSequences.end(), - std::back_inserter( aResult )); + aResult.insert( aResult.end(), aDataSequences.begin(), aDataSequences.end() ); } return uno::Reference< chart2::data::XDataSource >( @@ -335,8 +334,7 @@ uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData( if( !xDataSource.is() ) continue; uno::Sequence< uno::Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() ); - std::copy( aDataSequences.begin(), aDataSequences.end(), - std::back_inserter( aResult )); + aResult.insert( aResult.end(), aDataSequences.begin(), aDataSequences.end() ); } return uno::Reference< chart2::data::XDataSource >( diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 213d1787d1ce..5805f929aebb 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -670,8 +670,7 @@ std::vector< Reference< XDataSeries > > { Reference< XDataSeriesContainer > xDSCnt( chartType, uno::UNO_QUERY_THROW ); Sequence< Reference< XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() ); - std::copy( aSeriesSeq.begin(), aSeriesSeq.end(), - std::back_inserter( aResult )); + aResult.insert( aResult.end(), aSeriesSeq.begin(), aSeriesSeq.end() ); } } } @@ -1202,8 +1201,7 @@ Sequence< Reference< XChartType > > { Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW ); Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); - std::copy( aChartTypeSeq.begin(), aChartTypeSeq.end(), - std::back_inserter( aResult )); + aResult.insert( aResult.end(), aChartTypeSeq.begin(), aChartTypeSeq.end() ); } } catch( const uno::Exception & ) diff --git a/chart2/source/tools/ImplOPropertySet.cxx b/chart2/source/tools/ImplOPropertySet.cxx index d5f30096e49e..7d09a329fc33 100644 --- a/chart2/source/tools/ImplOPropertySet.cxx +++ b/chart2/source/tools/ImplOPropertySet.cxx @@ -92,8 +92,7 @@ ImplOPropertySet::ImplOPropertySet() ImplOPropertySet::ImplOPropertySet( const ImplOPropertySet & rOther ) { - std::copy( rOther.m_aProperties.begin(), rOther.m_aProperties.end(), - std::inserter( m_aProperties, m_aProperties.begin() )); + m_aProperties = rOther.m_aProperties; // clone interface properties std::for_each( m_aProperties.begin(), m_aProperties.end(), diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index 7c826e8f6129..ff89bc6dee92 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -456,9 +456,7 @@ void InternalDataProvider::adaptMapReferences( // erase map values for old index m_aSequenceMap.erase( aRange.first, aRange.second ); // add new entries for values with new index - std::copy( aNewElements.begin(), aNewElements.end(), - std::inserter( m_aSequenceMap, - m_aSequenceMap.upper_bound( rNewRangeRepresentation ))); + m_aSequenceMap.insert( aNewElements.begin(), aNewElements.end() ); } void InternalDataProvider::increaseMapReferences( -- cgit v1.2.3