summaryrefslogtreecommitdiff
path: root/toolkit/source
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-10-14 09:25:24 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2021-10-15 10:36:36 +0200
commit2484de6728bd11bb7949003d112f1ece2223c7a1 (patch)
tree1296534e396da284b38d2c478dcd2b31c4714179 /toolkit/source
parent88375fd36899d21d3309cf8333712e02a87d3a91 (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 'toolkit/source')
-rw-r--r--toolkit/source/controls/controlmodelcontainerbase.cxx2
-rw-r--r--toolkit/source/controls/geometrycontrolmodel.cxx2
-rw-r--r--toolkit/source/controls/stdtabcontroller.cxx4
-rw-r--r--toolkit/source/controls/unocontrol.cxx4
-rw-r--r--toolkit/source/controls/unocontrolcontainer.cxx4
-rw-r--r--toolkit/source/controls/unocontrolmodel.cxx6
-rw-r--r--toolkit/source/controls/unocontrols.cxx8
7 files changed, 15 insertions, 15 deletions
diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx
index c99c74dfb6c1..96599f3089bb 100644
--- a/toolkit/source/controls/controlmodelcontainerbase.cxx
+++ b/toolkit/source/controls/controlmodelcontainerbase.cxx
@@ -1471,7 +1471,7 @@ void ControlContainerBase::setDesignMode( sal_Bool bOn )
UnoControl::setDesignMode( bOn );
Sequence< Reference< XControl > > xCtrls = getControls();
- for ( Reference< XControl >& rControl : xCtrls )
+ for ( Reference< XControl >& rControl : asNonConstRange(xCtrls) )
rControl->setDesignMode( bOn );
// #109067# in design mode the tab controller is not notified about
diff --git a/toolkit/source/controls/geometrycontrolmodel.cxx b/toolkit/source/controls/geometrycontrolmodel.cxx
index ad738a24c00c..c201d9b15918 100644
--- a/toolkit/source/controls/geometrycontrolmodel.cxx
+++ b/toolkit/source/controls/geometrycontrolmodel.cxx
@@ -522,7 +522,7 @@ constexpr OUStringLiteral GCM_PROPERTY_RESOURCERESOLVER = u"ResourceResolver";
// look for duplicates, and remember them
IntArrayArray::value_type& rDuplicateIds = gAmbiguousPropertyIds[ _nId ];
// for this, sort the aggregate properties
- auto [begin, end] = toNonConstRange(aAggregateProps);
+ auto [begin, end] = asNonConstRange(aAggregateProps);
::std::sort(
begin,
end,
diff --git a/toolkit/source/controls/stdtabcontroller.cxx b/toolkit/source/controls/stdtabcontroller.cxx
index 1f9a3955770a..54d8a6a93782 100644
--- a/toolkit/source/controls/stdtabcontroller.cxx
+++ b/toolkit/source/controls/stdtabcontroller.cxx
@@ -218,7 +218,7 @@ Sequence< Reference< XControl > > StdTabController::getControls( )
sal_Int32 nCtrls = aModels.getLength();
aSeq = Sequence< Reference< XControl > >( nCtrls );
- std::transform(aModels.begin(), aModels.end(), aSeq.begin(),
+ std::transform(aModels.begin(), aModels.end(), aSeq.getArray(),
[&xCtrls](const Reference< XControlModel >& xCtrlModel) -> Reference< XControl > {
return FindControl( xCtrls, xCtrlModel ); });
}
@@ -284,7 +284,7 @@ void StdTabController::autoTabOrder( )
}
Sequence< Reference< XControlModel > > aNewSeq( nCtrls );
- std::transform(aCtrls.begin(), aCtrls.end(), aNewSeq.begin(),
+ std::transform(aCtrls.begin(), aCtrls.end(), aNewSeq.getArray(),
[](const ComponentEntry& rEntry) -> Reference< XControlModel > {
Reference< XControl > xUC( rEntry.pComponent, UNO_QUERY );
return xUC->getModel();
diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx
index 91b8dd756aa6..251c6261c8d4 100644
--- a/toolkit/source/controls/unocontrol.cxx
+++ b/toolkit/source/controls/unocontrol.cxx
@@ -86,7 +86,7 @@ static Sequence< OUString> lcl_ImplGetPropertyNames( const Reference< XMultiProp
const Sequence< Property> aProps = xPSInf->getProperties();
sal_Int32 nLen = aProps.getLength();
aNames = Sequence< OUString>( nLen );
- std::transform(aProps.begin(), aProps.end(), aNames.begin(),
+ std::transform(aProps.begin(), aProps.end(), aNames.getArray(),
[](const Property& rProp) -> OUString { return rProp.Name; });
}
return aNames;
@@ -278,7 +278,7 @@ void UnoControl::ImplSetPeerProperty( const OUString& rPropName, const Any& rVal
}
else if ( aConvertedValue >>= aSeqValue )
{
- for ( auto& rValue : aSeqValue )
+ for ( auto& rValue : asNonConstRange(aSeqValue) )
ImplCheckLocalize( rValue );
aConvertedValue <<= aSeqValue;
}
diff --git a/toolkit/source/controls/unocontrolcontainer.cxx b/toolkit/source/controls/unocontrolcontainer.cxx
index 30854ba16a6f..ae48bbe3c859 100644
--- a/toolkit/source/controls/unocontrolcontainer.cxx
+++ b/toolkit/source/controls/unocontrolcontainer.cxx
@@ -382,7 +382,7 @@ UnoControlContainer::~UnoControlContainer()
void UnoControlContainer::ImplActivateTabControllers()
{
- for ( auto& rTabController : maTabControllers )
+ for ( auto& rTabController : asNonConstRange(maTabControllers) )
{
rTabController->setContainer( this );
rTabController->activateTabOrder();
@@ -750,7 +750,7 @@ void UnoControlContainer::createPeer( const uno::Reference< awt::XToolkit >& rxT
}
uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
- for( auto& rCtrl : aCtrls )
+ for( auto& rCtrl : asNonConstRange(aCtrls) )
rCtrl->createPeer( rxToolkit, getPeer() );
uno::Reference< awt::XVclContainerPeer > xC( getPeer(), uno::UNO_QUERY );
diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx
index 9f62a1ebc241..0bb8ca566368 100644
--- a/toolkit/source/controls/unocontrolmodel.cxx
+++ b/toolkit/source/controls/unocontrolmodel.cxx
@@ -496,7 +496,7 @@ css::uno::Sequence< css::beans::PropertyState > UnoControlModel::getPropertyStat
css::uno::Sequence< css::beans::PropertyState > aStates( nNames );
- std::transform(PropertyNames.begin(), PropertyNames.end(), aStates.begin(),
+ std::transform(PropertyNames.begin(), PropertyNames.end(), aStates.getArray(),
[this](const OUString& rName) -> css::beans::PropertyState { return getPropertyState(rName); });
return aStates;
@@ -665,7 +665,7 @@ void UnoControlModel::write( const css::uno::Reference< css::io::XObjectOutputSt
rValue >>= aSeq;
tools::Long nEntries = aSeq.getLength();
OutStream->writeLong( nEntries );
- for ( const auto nVal : aSeq )
+ for ( const auto nVal : std::as_const(aSeq) )
OutStream->writeShort( nVal );
}
else if ( rType == cppu::UnoType< css::uno::Sequence<sal_Int16> >::get() )
@@ -674,7 +674,7 @@ void UnoControlModel::write( const css::uno::Reference< css::io::XObjectOutputSt
rValue >>= aSeq;
tools::Long nEntries = aSeq.getLength();
OutStream->writeLong( nEntries );
- for ( const auto nVal : aSeq )
+ for ( const auto nVal : std::as_const(aSeq) )
OutStream->writeShort( nVal );
}
else if ( rType.getTypeClass() == TypeClass_ENUM )
diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx
index 02ecedeb0389..034be82a3d7c 100644
--- a/toolkit/source/controls/unocontrols.cxx
+++ b/toolkit/source/controls/unocontrols.cxx
@@ -2605,7 +2605,7 @@ void UnoListBoxControl::addItems( const uno::Sequence< OUString>& aItems, sal_In
nPos = nOldLen;
// Items before the Paste-Position
- auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.begin());
+ auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.getArray());
// New Items
it = std::copy(aItems.begin(), aItems.end(), it);
@@ -2633,7 +2633,7 @@ void UnoListBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount )
uno::Sequence< OUString> aNewSeq( nNewLen );
// Items before the Remove-Position
- auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.begin());
+ auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.getArray());
// Rest of Items
std::copy(std::next(std::cbegin(aSeq), nPos + nCount), std::cend(aSeq), it);
@@ -3197,7 +3197,7 @@ void UnoComboBoxControl::addItems( const uno::Sequence< OUString>& aItems, sal_I
nPos = nOldLen;
// items before the insert position
- auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.begin());
+ auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.getArray());
// New items
it = std::copy(aItems.begin(), aItems.end(), it);
@@ -3225,7 +3225,7 @@ void UnoComboBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount )
uno::Sequence< OUString> aNewSeq( nNewLen );
// items before the deletion position
- auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.begin());
+ auto it = std::copy(std::cbegin(aSeq), std::next(std::cbegin(aSeq), nPos), aNewSeq.getArray());
// remainder of old items
std::copy(std::next(std::cbegin(aSeq), nPos + nCount), std::cend(aSeq), it);