summaryrefslogtreecommitdiff
path: root/connectivity
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 /connectivity
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 'connectivity')
-rw-r--r--connectivity/source/commontools/ConnectionWrapper.cxx2
-rw-r--r--connectivity/source/commontools/dbtools.cxx9
-rw-r--r--connectivity/source/drivers/jdbc/JStatement.cxx2
-rw-r--r--connectivity/source/drivers/odbc/OStatement.cxx2
-rw-r--r--connectivity/source/sdbcx/VDescriptor.cxx2
5 files changed, 7 insertions, 10 deletions
diff --git a/connectivity/source/commontools/ConnectionWrapper.cxx b/connectivity/source/commontools/ConnectionWrapper.cxx
index 252882067865..8a0cc852ed98 100644
--- a/connectivity/source/commontools/ConnectionWrapper.cxx
+++ b/connectivity/source/commontools/ConnectionWrapper.cxx
@@ -199,7 +199,7 @@ void OConnectionWrapper::createUniqueId( const OUString& _rURL
if ( !_rPassword.isEmpty() )
sha1.update(reinterpret_cast<unsigned char const*>(_rPassword.getStr()), _rPassword.getLength() * sizeof(sal_Unicode));
// now we need to sort the properties
- auto [begin, end] = toNonConstRange(_rInfo);
+ auto [begin, end] = asNonConstRange(_rInfo);
std::sort(begin,end,TPropertyValueLessFunctor());
for (PropertyValue const & prop : std::as_const(_rInfo))
diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
index 40a07679ba96..88f9e37760c0 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -947,10 +947,7 @@ try
Reference< XPropertySetInfo> xNewInfo( xNewProps->getPropertySetInfo());
const Sequence< Property> aOldProperties = xOldInfo->getProperties();
- Sequence< Property> aNewProperties = xNewInfo->getProperties();
- int nNewLen = aNewProperties.getLength();
-
- Property* pNewProps = aNewProperties.getArray();
+ const Sequence< Property> aNewProperties = xNewInfo->getProperties();
static constexpr OUStringLiteral sPropFormatsSupplier(u"FormatsSupplier");
static constexpr OUStringLiteral sPropCurrencySymbol(u"CurrencySymbol");
@@ -972,8 +969,8 @@ try
if ( rOldProp.Name != "DefaultControl" && rOldProp.Name != "LabelControl" )
{
// binary search
- Property* pResult = std::lower_bound(
- pNewProps, pNewProps + nNewLen, rOldProp, ::comphelper::PropertyCompareByName());
+ const Property* pResult = std::lower_bound(
+ aNewProperties.begin(), aNewProperties.end(), rOldProp, ::comphelper::PropertyCompareByName());
if ( ( pResult != aNewProperties.end() )
&& ( pResult->Name == rOldProp.Name )
diff --git a/connectivity/source/drivers/jdbc/JStatement.cxx b/connectivity/source/drivers/jdbc/JStatement.cxx
index da06ef77f2c3..df9d660f554c 100644
--- a/connectivity/source/drivers/jdbc/JStatement.cxx
+++ b/connectivity/source/drivers/jdbc/JStatement.cxx
@@ -124,7 +124,7 @@ Sequence< Type > SAL_CALL java_sql_Statement_Base::getTypes( )
Sequence< Type > aOldTypes = java_sql_Statement_BASE::getTypes();
if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() )
{
- auto [begin, end] = toNonConstRange(aOldTypes);
+ auto [begin, end] = asNonConstRange(aOldTypes);
auto newEnd = std::remove(begin, end,
cppu::UnoType<XGeneratedResultSet>::get());
aOldTypes.realloc(std::distance(begin, newEnd));
diff --git a/connectivity/source/drivers/odbc/OStatement.cxx b/connectivity/source/drivers/odbc/OStatement.cxx
index 13ffeda8e4ba..d44f86e58469 100644
--- a/connectivity/source/drivers/odbc/OStatement.cxx
+++ b/connectivity/source/drivers/odbc/OStatement.cxx
@@ -131,7 +131,7 @@ Sequence< Type > SAL_CALL OStatement_Base::getTypes( )
Sequence< Type > aOldTypes = OStatement_BASE::getTypes();
if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() )
{
- auto [begin, end] = toNonConstRange(aOldTypes);
+ auto [begin, end] = asNonConstRange(aOldTypes);
auto newEnd = std::remove(begin, end,
cppu::UnoType<XGeneratedResultSet>::get());
aOldTypes.realloc(std::distance(begin, newEnd));
diff --git a/connectivity/source/sdbcx/VDescriptor.cxx b/connectivity/source/sdbcx/VDescriptor.cxx
index 2392e2d5f1d2..7800aaf075be 100644
--- a/connectivity/source/sdbcx/VDescriptor.cxx
+++ b/connectivity/source/sdbcx/VDescriptor.cxx
@@ -74,7 +74,7 @@ namespace connectivity::sdbcx
Sequence< Property > aProperties;
describeProperties( aProperties );
- auto [begin, end] = toNonConstRange(aProperties);
+ auto [begin, end] = asNonConstRange(aProperties);
if ( isNew() )
std::for_each( begin, end, ResetROAttribute() );
else