From 2484de6728bd11bb7949003d112f1ece2223c7a1 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Thu, 14 Oct 2021 09:25:24 +0200 Subject: Remove non-const Sequence::begin()/end() in internal code ... to avoid hidden cost of multiple COW checks, because they call getArray() internally. This obsoletes [loplugin:sequenceloop]. Also rename toNonConstRange to asNonConstRange, to reflect that the result is a view of the sequence, not an independent object. TODO: also drop non-const operator[], but introduce operator[] in SequenceRange. Change-Id: Idd5fd7a3400fe65274d2a6343025e2ef8911635d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123518 Tested-by: Jenkins Reviewed-by: Stephan Bergmann Reviewed-by: Mike Kaganski --- .../source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx | 2 +- chart2/source/model/template/ColumnLineDataInterpreter.cxx | 4 ++-- chart2/source/tools/ReferenceSizeProvider.cxx | 4 ++-- chart2/source/view/axes/VCoordinateSystem.cxx | 4 ++-- chart2/source/view/main/VDataSeries.cxx | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx index adaa328e636d..e48ba0b3f443 100644 --- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx @@ -219,7 +219,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf if(!bGroupBarsPerAxis) { //set the same value for all axes - for( auto & pos : aBarPositionSequence ) + for( auto & pos : asNonConstRange(aBarPositionSequence) ) pos = rBarPosition; } else if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) diff --git a/chart2/source/model/template/ColumnLineDataInterpreter.cxx b/chart2/source/model/template/ColumnLineDataInterpreter.cxx index f59c98c489b6..6069255d3f1d 100644 --- a/chart2/source/model/template/ColumnLineDataInterpreter.cxx +++ b/chart2/source/model/template/ColumnLineDataInterpreter.cxx @@ -64,8 +64,8 @@ InterpretedData SAL_CALL ColumnLineDataInterpreter::interpretDataSource( Sequence< Reference< XDataSeries > > & rColumnDataSeries = aResult.Series[0]; Sequence< Reference< XDataSeries > > & rLineDataSeries = aResult.Series[1]; rLineDataSeries.realloc( nNumOfLines ); - std::copy( rColumnDataSeries.begin() + nNumberOfSeries - nNumOfLines, - rColumnDataSeries.begin() + nNumberOfSeries, + std::copy( std::cbegin(rColumnDataSeries) + nNumberOfSeries - nNumOfLines, + std::cbegin(rColumnDataSeries) + nNumberOfSeries, rLineDataSeries.getArray() ); rColumnDataSeries.realloc( nNumberOfSeries - nNumOfLines ); } diff --git a/chart2/source/tools/ReferenceSizeProvider.cxx b/chart2/source/tools/ReferenceSizeProvider.cxx index b5b928e9e843..b409c1730e39 100644 --- a/chart2/source/tools/ReferenceSizeProvider.cxx +++ b/chart2/source/tools/ReferenceSizeProvider.cxx @@ -108,7 +108,7 @@ void ReferenceSizeProvider::setValuesAtAllDataSeries() { if( xSeriesProp->getPropertyValue( "AttributedDataPoints") >>= aPointIndexes ) { - for( sal_Int32 idx : aPointIndexes ) + for( sal_Int32 idx : std::as_const(aPointIndexes) ) setValuesAtPropertySet( elem->getDataPointByIndex( idx ) ); } @@ -282,7 +282,7 @@ ReferenceSizeProvider::AutoResizeState ReferenceSizeProvider::getAutoResizeState { if( xSeriesProp->getPropertyValue( "AttributedDataPoints") >>= aPointIndexes ) { - for( sal_Int32 idx : aPointIndexes ) + for( sal_Int32 idx : std::as_const(aPointIndexes) ) { getAutoResizeFromPropSet( elem->getDataPointByIndex( idx ), eResult ); diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx index 7259f3e92043..a320c85cb497 100644 --- a/chart2/source/view/axes/VCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCoordinateSystem.cxx @@ -141,7 +141,7 @@ uno::Sequence< sal_Int32 > VCoordinateSystem::getCoordinateSystemResolution( uno::Sequence aResolution( std::max(m_xCooSysModel->getDimension(), 2)); - for( auto& i : aResolution ) + for( auto& i : asNonConstRange(aResolution) ) i = 1000; ::basegfx::B3DTuple aScale( BaseGFXHelper::GetScaleFromMatrix( @@ -177,7 +177,7 @@ uno::Sequence< sal_Int32 > VCoordinateSystem::getCoordinateSystemResolution( //this maybe can be optimized further ... sal_Int32 nMaxResolution = std::max( nXResolution, nYResolution ); nMaxResolution*=2; - for( auto& i : aResolution ) + for( auto& i : asNonConstRange(aResolution) ) i = nMaxResolution; } diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index b3047d4126b3..0d3123a8cb13 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -582,7 +582,7 @@ sal_Int32 VDataSeries::getLabelPlacement( sal_Int32 nPointIndex, const uno::Refe if( xPointProps.is() ) xPointProps->getPropertyValue("LabelPlacement") >>= nLabelPlacement; - uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements( + const uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements( xChartType, bSwapXAndY, m_xDataSeries ) ); for( sal_Int32 n : aAvailablePlacements ) -- cgit