diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-14 09:25:24 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-15 10:36:36 +0200 |
commit | 2484de6728bd11bb7949003d112f1ece2223c7a1 (patch) | |
tree | 1296534e396da284b38d2c478dcd2b31c4714179 /svx | |
parent | 88375fd36899d21d3309cf8333712e02a87d3a91 (diff) |
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 <sbergman@redhat.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/accessibility/AccessibleControlShape.cxx | 4 | ||||
-rw-r--r-- | svx/source/dialog/SvxNumOptionsTabPageHelper.cxx | 2 | ||||
-rw-r--r-- | svx/source/dialog/rubydialog.cxx | 18 | ||||
-rw-r--r-- | svx/source/fmcomp/fmgridcl.cxx | 2 | ||||
-rw-r--r-- | svx/source/fmcomp/fmgridif.cxx | 2 | ||||
-rw-r--r-- | svx/source/form/formdispatchinterceptor.cxx | 2 | ||||
-rw-r--r-- | svx/source/table/cell.cxx | 4 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbunosearchcontrollers.cxx | 2 | ||||
-rw-r--r-- | svx/source/unodraw/UnoGraphicExporter.cxx | 2 | ||||
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 2 |
10 files changed, 18 insertions, 22 deletions
diff --git a/svx/source/accessibility/AccessibleControlShape.cxx b/svx/source/accessibility/AccessibleControlShape.cxx index 94e3aab617fe..f2714a8ab9b0 100644 --- a/svx/source/accessibility/AccessibleControlShape.cxx +++ b/svx/source/accessibility/AccessibleControlShape.cxx @@ -784,7 +784,7 @@ void AccessibleControlShape::initializeComposedState() #if OSL_DEBUG_LEVEL > 0 // now, only states which are not in the responsibility of the UNO control should be part of this state set { - Sequence< sal_Int16 > aInitStates = pComposedStates->getStates(); + const Sequence< sal_Int16 > aInitStates = pComposedStates->getStates(); for ( sal_Int16 state : aInitStates ) OSL_ENSURE( !isComposedState( state ), "AccessibleControlShape::initializeComposedState: invalid initial composed state (should be controlled by the UNO-control)!" ); @@ -805,7 +805,7 @@ void AccessibleControlShape::initializeComposedState() aInnerStates = xInnerStates->getStates(); // look which one are to be propagated to the composed context - for ( const sal_Int16 nState : aInnerStates ) + for ( const sal_Int16 nState : std::as_const(aInnerStates) ) { if ( isComposedState( nState ) && !pComposedStates->contains( nState ) ) { diff --git a/svx/source/dialog/SvxNumOptionsTabPageHelper.cxx b/svx/source/dialog/SvxNumOptionsTabPageHelper.cxx index 7c6e010e9c2f..0236c88353db 100644 --- a/svx/source/dialog/SvxNumOptionsTabPageHelper.cxx +++ b/svx/source/dialog/SvxNumOptionsTabPageHelper.cxx @@ -53,7 +53,7 @@ void SvxNumOptionsTabPageHelper::GetI18nNumbering(weld::ComboBox& rFmtLB, sal_uI } if (xInfo.is()) { - Sequence<sal_Int16> aTypes = xInfo->getSupportedNumberingTypes(); + const Sequence<sal_Int16> aTypes = xInfo->getSupportedNumberingTypes(); for (const sal_Int16 nCurrent : aTypes) { if (nCurrent > NumberingType::CHARS_LOWER_LETTER_N) diff --git a/svx/source/dialog/rubydialog.cxx b/svx/source/dialog/rubydialog.cxx index 845ea5b74140..b10e6deb580e 100644 --- a/svx/source/dialog/rubydialog.cxx +++ b/svx/source/dialog/rubydialog.cxx @@ -387,8 +387,7 @@ void SvxRubyDialog::GetRubyText() Sequence<PropertyValues>& aRubyValues = m_pImpl->GetRubyValues(); DBG_ASSERT(aRubyValues.getLength() > (i / 2 + nTempLastPos), "wrong index"); SetModified(true); - Sequence<PropertyValue>& rProps = aRubyValues.getArray()[i / 2 + nTempLastPos]; - for (PropertyValue& propVal : rProps) + for (PropertyValue& propVal : asNonConstRange(aRubyValues[i / 2 + nTempLastPos])) { if (propVal.Name == cRubyBaseText) propVal.Value <<= aEditArr[i]->get_text(); @@ -547,10 +546,9 @@ IMPL_LINK(SvxRubyDialog, AdjustHdl_Impl, weld::ComboBox&, rBox, void) { AssertOneEntry(); sal_Int16 nAdjust = rBox.get_active(); - Sequence<PropertyValues>& aRubyValues = m_pImpl->GetRubyValues(); - for (PropertyValues& rProps : aRubyValues) + for (PropertyValues& rProps : asNonConstRange(m_pImpl->GetRubyValues())) { - for (PropertyValue& propVal : rProps) + for (PropertyValue& propVal : asNonConstRange(rProps)) { if (propVal.Name == cRubyAdjust) propVal.Value <<= nAdjust; @@ -564,10 +562,9 @@ IMPL_LINK(SvxRubyDialog, PositionHdl_Impl, weld::ComboBox&, rBox, void) { AssertOneEntry(); sal_Int16 nPosition = rBox.get_active(); - Sequence<PropertyValues>& aRubyValues = m_pImpl->GetRubyValues(); - for (PropertyValues& rProps : aRubyValues) + for (PropertyValues& rProps : asNonConstRange(m_pImpl->GetRubyValues())) { - for (PropertyValue& propVal : rProps) + for (PropertyValue& propVal : asNonConstRange(rProps)) { if (propVal.Name == cRubyPosition) propVal.Value <<= nPosition; @@ -583,10 +580,9 @@ IMPL_LINK_NOARG(SvxRubyDialog, CharStyleHdl_Impl, weld::ComboBox&, void) OUString sStyleName; if (m_xCharStyleLB->get_active() != -1) sStyleName = m_xCharStyleLB->get_active_id(); - Sequence<PropertyValues>& aRubyValues = m_pImpl->GetRubyValues(); - for (PropertyValues& rProps : aRubyValues) + for (PropertyValues& rProps : asNonConstRange(m_pImpl->GetRubyValues())) { - for (PropertyValue& propVal : rProps) + for (PropertyValue& propVal : asNonConstRange(rProps)) { if (propVal.Name == cRubyCharStyleName) { diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx index d7f5ee2e0a64..dc9fa4100814 100644 --- a/svx/source/fmcomp/fmgridcl.cxx +++ b/svx/source/fmcomp/fmgridcl.cxx @@ -1381,7 +1381,7 @@ void FmGridControl::DeleteSelectedRows() else { // select the remaining rows - for (const sal_Int32 nSuccess : aDeletedRows) + for (const sal_Int32 nSuccess : std::as_const(aDeletedRows)) { try { diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index ab52cb90864a..40e4eefd7d44 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -2653,7 +2653,7 @@ Sequence< css::util::URL>& FmXGridPeer::getSupportedURLs() // let a css::util::URL-transformer normalize the URLs Reference< css::util::XURLTransformer > xTransformer( util::URLTransformer::create(::comphelper::getProcessComponentContext()) ); - for (css::util::URL & rURL : tmp) + for (css::util::URL & rURL : asNonConstRange(tmp)) xTransformer->parseStrict(rURL); return tmp; }(); diff --git a/svx/source/form/formdispatchinterceptor.cxx b/svx/source/form/formdispatchinterceptor.cxx index 0b84e57d9d1a..cc75b0b01f30 100644 --- a/svx/source/form/formdispatchinterceptor.cxx +++ b/svx/source/form/formdispatchinterceptor.cxx @@ -89,7 +89,7 @@ namespace svxform { ::osl::MutexGuard aGuard( *m_pMutex ); Sequence< Reference< XDispatch> > aReturn(aDescripts.getLength()); - std::transform(aDescripts.begin(), aDescripts.end(), aReturn.begin(), + std::transform(aDescripts.begin(), aDescripts.end(), aReturn.getArray(), [this](const DispatchDescriptor& rDescript) -> Reference< XDispatch> { return queryDispatch(rDescript.FeatureURL, rDescript.FrameName, rDescript.SearchFlags); }); return aReturn; diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index 3abce7c4d820..134becd88e8b 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -1462,7 +1462,7 @@ Sequence< PropertyState > SAL_CALL Cell::getPropertyStates( const Sequence< OUSt const sal_Int32 nCount = aPropertyName.getLength(); Sequence< PropertyState > aRet( nCount ); - std::transform(aPropertyName.begin(), aPropertyName.end(), aRet.begin(), + std::transform(aPropertyName.begin(), aPropertyName.end(), aRet.getArray(), [this](const OUString& rName) -> PropertyState { try { @@ -1602,7 +1602,7 @@ Sequence< Any > SAL_CALL Cell::getPropertyDefaults( const Sequence< OUString >& sal_Int32 nCount = aPropertyNames.getLength(); Sequence< Any > aDefaults( nCount ); - std::transform(aPropertyNames.begin(), aPropertyNames.end(), aDefaults.begin(), + std::transform(aPropertyNames.begin(), aPropertyNames.end(), aDefaults.getArray(), [this](const OUString& rName) -> Any { return getPropertyDefault(rName); }); return aDefaults; diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index d315e79f9b3b..75a08ed16973 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -1504,7 +1504,7 @@ css::uno::Sequence < css::uno::Reference< css::frame::XDispatch > > SAL_CALL Fin sal_Int32 nCount = seqDescripts.getLength(); css::uno::Sequence < css::uno::Reference < XDispatch > > lDispatcher( nCount ); - std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.begin(), + std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.getArray(), [this](const css::frame::DispatchDescriptor& rDescript) -> css::uno::Reference < XDispatch > { return queryDispatch( rDescript.FeatureURL, rDescript.FrameName, rDescript.SearchFlags ); }); diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index 843bca3967b5..2fc756fa0fdb 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -495,7 +495,7 @@ void GraphicExporter::ParseSettings( const Sequence< PropertyValue >& aDescripto { rValue.Value >>= rSettings.maFilterData; - for( PropertyValue& rDataValue : rSettings.maFilterData ) + for( PropertyValue& rDataValue : asNonConstRange(rSettings.maFilterData) ) { if ( rDataValue.Name == "Translucent" ) { diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 47676618c106..c7fc27260744 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -3016,7 +3016,7 @@ uno::Sequence< beans::PropertyState > SAL_CALL SvxShape::getPropertyStates( cons const sal_Int32 nCount = aPropertyName.getLength(); uno::Sequence< beans::PropertyState > aRet( nCount ); - std::transform(aPropertyName.begin(), aPropertyName.end(), aRet.begin(), + std::transform(aPropertyName.begin(), aPropertyName.end(), aRet.getArray(), [this](const OUString& rName) -> beans::PropertyState { return getPropertyState(rName); }); return aRet; |