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 /dbaccess | |
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 'dbaccess')
-rw-r--r-- | dbaccess/source/core/api/TableDeco.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/core/api/definitioncolumn.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/core/api/table.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/databasedocument.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/datasource.cxx | 4 | ||||
-rw-r--r-- | dbaccess/source/filter/xml/xmlExport.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/formadapter.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/sbamultiplex.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/unodatbr.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/querycontroller.cxx | 2 |
11 files changed, 12 insertions, 12 deletions
diff --git a/dbaccess/source/core/api/TableDeco.cxx b/dbaccess/source/core/api/TableDeco.cxx index f40593b8598d..1448c657abd4 100644 --- a/dbaccess/source/core/api/TableDeco.cxx +++ b/dbaccess/source/core/api/TableDeco.cxx @@ -310,7 +310,7 @@ void ODBTableDecorator::construct() Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo(); Sequence< Property > aTableProps = xInfo->getProperties(); - for (Property & prop : aTableProps) + for (Property & prop : asNonConstRange(aTableProps)) { if (prop.Name == PROPERTY_CATALOGNAME) prop.Handle = PROPERTY_ID_CATALOGNAME; diff --git a/dbaccess/source/core/api/definitioncolumn.cxx b/dbaccess/source/core/api/definitioncolumn.cxx index 7854a97f1816..beff8adf7f03 100644 --- a/dbaccess/source/core/api/definitioncolumn.cxx +++ b/dbaccess/source/core/api/definitioncolumn.cxx @@ -487,7 +487,7 @@ Sequence< OUString > OTableColumnDescriptorWrapper::getSupportedServiceNames( ) if ( !m_bIsDescriptor ) { - for ( auto & prop : aDescriptor ) + for ( auto & prop : asNonConstRange(aDescriptor) ) { prop.Attributes |= PropertyAttribute::READONLY; } diff --git a/dbaccess/source/core/api/table.cxx b/dbaccess/source/core/api/table.cxx index f11008555ca9..b4b6e47cd57d 100644 --- a/dbaccess/source/core/api/table.cxx +++ b/dbaccess/source/core/api/table.cxx @@ -211,7 +211,7 @@ void ODBTable::construct() describeProperties(aProps); if(!_nId) { - for(Property & prop : aProps) + for(Property & prop : asNonConstRange(aProps)) { if (prop.Name == PROPERTY_CATALOGNAME) prop.Attributes = PropertyAttribute::READONLY; diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index e9867def1b99..c38dc9429cfc 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -223,7 +223,7 @@ Sequence< Type > SAL_CALL ODatabaseDocument::getTypes( ) // allowed to contain macros, too. if ( !m_bAllowDocumentScripting ) { - auto [begin, end] = toNonConstRange(aTypes); + auto [begin, end] = asNonConstRange(aTypes); auto newEnd = std::remove_if( begin, end, [](const Type& t) { return t == cppu::UnoType<XEmbeddedScripts>::get() || diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx index 48039c3e6943..b36ac6ea67b6 100644 --- a/dbaccess/source/core/dataaccess/datasource.cxx +++ b/dbaccess/source/core/dataaccess/datasource.cxx @@ -866,7 +866,7 @@ sal_Bool ODatabaseSource::convertFastPropertyValue(Any & rConvertedValue, Any & { const PropertyValue* pInfoIter = aSettings.getConstArray(); const PropertyValue* checkValue = aValues.getConstArray(); - for ( ;!bModified && checkValue != aValues.end() ; ++checkValue,++pInfoIter) + for ( ;!bModified && checkValue != std::cend(aValues) ; ++checkValue,++pInfoIter) { bModified = checkValue->Name != pInfoIter->Name; if ( !bModified ) @@ -1046,7 +1046,7 @@ void ODatabaseSource::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) con // transform them so that only property values which fulfill certain // criteria survive Sequence< PropertyValue > aNonDefaultOrUserDefined( aValues.getLength() ); - auto [begin, end] = toNonConstRange(aValues); + auto [begin, end] = asNonConstRange(aValues); auto pCopyStart = aNonDefaultOrUserDefined.getArray(); const PropertyValue* pCopyEnd = std::remove_copy_if( begin, diff --git a/dbaccess/source/filter/xml/xmlExport.cxx b/dbaccess/source/filter/xml/xmlExport.cxx index e0c1304c8cc6..b2b6ae0ce395 100644 --- a/dbaccess/source/filter/xml/xmlExport.cxx +++ b/dbaccess/source/filter/xml/xmlExport.cxx @@ -595,7 +595,7 @@ template< typename T > void ODBExport::exportDataSourceSettingsSequence( css::uno::Sequence<T> anySeq; bool bSuccess = in->Value >>= anySeq; assert(bSuccess); (void)bSuccess; - for (T const & i : anySeq ) + for (T const & i : std::as_const(anySeq) ) { SvXMLElementExport aDataValue(*this,XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_VALUE, true, false); // (no whitespace inside the tag) diff --git a/dbaccess/source/ui/browser/formadapter.cxx b/dbaccess/source/ui/browser/formadapter.cxx index 7a07f0a9d206..37f35a0472ee 100644 --- a/dbaccess/source/ui/browser/formadapter.cxx +++ b/dbaccess/source/ui/browser/formadapter.cxx @@ -1326,7 +1326,7 @@ Sequence< css::beans::PropertyState> SAL_CALL SbaXFormAdapter::getPropertyStates // set them all to DEFAULT Sequence< css::beans::PropertyState> aReturn(aPropertyName.getLength()); - for (css::beans::PropertyState& rState : aReturn) + for (css::beans::PropertyState& rState : asNonConstRange(aReturn)) rState = css::beans::PropertyState_DEFAULT_VALUE; return aReturn; } diff --git a/dbaccess/source/ui/browser/sbamultiplex.cxx b/dbaccess/source/ui/browser/sbamultiplex.cxx index 68673fd06ff2..f31b4c7ac27f 100644 --- a/dbaccess/source/ui/browser/sbamultiplex.cxx +++ b/dbaccess/source/ui/browser/sbamultiplex.cxx @@ -85,7 +85,7 @@ void SbaXPropertiesChangeMultiplexer::propertiesChange(const css::uno::Sequence< // forwards _all_ changes to _all_ listeners css::uno::Sequence< css::beans::PropertyChangeEvent> aMulti(aEvts); - for (css::beans::PropertyChangeEvent & rEvent : aMulti) + for (css::beans::PropertyChangeEvent & rEvent : asNonConstRange(aMulti)) rEvent.Source = &m_rParent; ::comphelper::OInterfaceIteratorHelper2 aIt(*this); diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index b6bf10274b8b..035a0e1ef8c2 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -214,7 +214,7 @@ Sequence< Type > SAL_CALL SbaTableQueryBrowser::getTypes( ) OSL_PRECOND( !!m_aDocScriptSupport, "SbaTableQueryBrowser::getTypes: did not initialize this, yet!" ); if ( !m_aDocScriptSupport || !*m_aDocScriptSupport ) { - auto [begin, end] = toNonConstRange(aTypes); + auto [begin, end] = asNonConstRange(aTypes); auto newEnd = std::remove_if( begin, end, [](const Type& type) { return type == cppu::UnoType<XScriptInvocationContext>::get(); } ); diff --git a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx index 82ce80f71333..b77953316ec7 100644 --- a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx +++ b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx @@ -222,7 +222,7 @@ namespace dbaui Sequence< Type > aTypes( DBSubComponentController_Base::getTypes() ); if ( !m_pImpl->documentHasScriptSupport() ) { - auto [begin, end] = toNonConstRange(aTypes); + auto [begin, end] = asNonConstRange(aTypes); auto newEnd = std::remove_if( begin, end, [](const Type& type) { return type == cppu::UnoType<XScriptInvocationContext>::get(); } ); diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 4f7bd55bde1e..9500281a7275 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -288,7 +288,7 @@ void SAL_CALL OQueryController::getFastPropertyValue( Any& o_rValue, sal_Int32 i PropertyAttribute::READONLY ); - auto [begin, end] = toNonConstRange(aProps); + auto [begin, end] = asNonConstRange(aProps); std::sort( begin, end, |