summaryrefslogtreecommitdiff
path: root/sw/source/uibase
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 /sw/source/uibase
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 'sw/source/uibase')
-rw-r--r--sw/source/uibase/dbui/dbtree.cxx2
-rw-r--r--sw/source/uibase/dbui/mmconfigitem.cxx6
-rw-r--r--sw/source/uibase/fldui/fldmgr.cxx4
-rw-r--r--sw/source/uibase/misc/numberingtypelistbox.cxx2
-rw-r--r--sw/source/uibase/uno/unodispatch.cxx2
-rw-r--r--sw/source/uibase/uno/unomodule.cxx2
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx4
7 files changed, 11 insertions, 11 deletions
diff --git a/sw/source/uibase/dbui/dbtree.cxx b/sw/source/uibase/dbui/dbtree.cxx
index 0af160098e08..941df07e1ec7 100644
--- a/sw/source/uibase/dbui/dbtree.cxx
+++ b/sw/source/uibase/dbui/dbtree.cxx
@@ -150,7 +150,7 @@ void SwDBTreeList::InitTreeList()
auto const sort = comphelper::string::NaturalStringSorter(
comphelper::getProcessComponentContext(),
Application::GetSettings().GetUILanguageTag().getLocale());
- auto [begin, end] = toNonConstRange(aDBNames);
+ auto [begin, end] = asNonConstRange(aDBNames);
std::sort(
begin, end,
[&sort](OUString const & x, OUString const & y)
diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx
index 4dd6d7e0a5c4..36986ba59f5e 100644
--- a/sw/source/uibase/dbui/mmconfigitem.cxx
+++ b/sw/source/uibase/dbui/mmconfigitem.cxx
@@ -333,7 +333,7 @@ SwMailMergeConfigItem_Impl::SwMailMergeConfigItem_Impl() :
if(m_aSavedDocuments.hasElements())
{
uno::Sequence< OUString > aTempDocuments(m_aSavedDocuments.getLength());
- auto begin = aTempDocuments.begin();
+ auto begin = aTempDocuments.getArray();
OUString* pTempDocuments = std::copy_if(std::cbegin(m_aSavedDocuments), std::cend(m_aSavedDocuments), begin,
[](const OUString& rDoc) { return SWUnoHelper::UCB_IsFile( rDoc ); });
sal_Int32 nIndex = static_cast<sal_Int32>(std::distance(begin, pTempDocuments));
@@ -585,7 +585,7 @@ Sequence< OUString> SwMailMergeConfigItem_Impl::GetAddressBlocks(
bool bConvertToConfig) const
{
Sequence< OUString> aRet(m_aAddressBlocks.size());
- std::transform(m_aAddressBlocks.begin(), m_aAddressBlocks.end(), aRet.begin(),
+ std::transform(m_aAddressBlocks.begin(), m_aAddressBlocks.end(), aRet.getArray(),
[this, bConvertToConfig](const OUString& rBlock) -> OUString {
OUString sBlock = rBlock;
if(bConvertToConfig)
@@ -619,7 +619,7 @@ Sequence< OUString> SwMailMergeConfigItem_Impl::GetGreetings(
eType == SwMailMergeConfigItem::MALE ? m_aMaleGreetingLines :
m_aNeutralGreetingLines;
Sequence< OUString> aRet(rGreetings.size());
- std::transform(rGreetings.begin(), rGreetings.end(), aRet.begin(),
+ std::transform(rGreetings.begin(), rGreetings.end(), aRet.getArray(),
[this, bConvertToConfig](const OUString& rGreeting) -> OUString {
OUString sGreeting = rGreeting;
if(bConvertToConfig)
diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx
index 634bedb8c1c0..013c65198f1f 100644
--- a/sw/source/uibase/fldui/fldmgr.cxx
+++ b/sw/source/uibase/fldui/fldmgr.cxx
@@ -738,7 +738,7 @@ OUString SwFieldMgr::GetFormatStr(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId
{
if (m_xNumberingInfo.is())
{
- Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
+ const Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
sal_Int32 nOffset = aSwFields[nPos].nFormatLength;
sal_uInt32 nValidEntry = 0;
for (const sal_Int16 nCurrent : aTypes)
@@ -818,7 +818,7 @@ sal_uInt16 SwFieldMgr::GetFormatId(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatI
}
else if (m_xNumberingInfo.is())
{
- Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
+ const Sequence<sal_Int16> aTypes = m_xNumberingInfo->getSupportedNumberingTypes();
sal_Int32 nOffset = aSwFields[nPos].nFormatLength;
sal_Int32 nValidEntry = 0;
for (const sal_Int16 nCurrent : aTypes)
diff --git a/sw/source/uibase/misc/numberingtypelistbox.cxx b/sw/source/uibase/misc/numberingtypelistbox.cxx
index 5f4c45bb8dfc..94a26bcb9ffc 100644
--- a/sw/source/uibase/misc/numberingtypelistbox.cxx
+++ b/sw/source/uibase/misc/numberingtypelistbox.cxx
@@ -101,7 +101,7 @@ void SwNumberingTypeListBox::Reload(SwInsertNumTypes nTypeFlags)
if (!(nTypeFlags & SwInsertNumTypes::Extended))
return;
- for (sal_Int16 nCurrent : aTypes)
+ for (sal_Int16 nCurrent : std::as_const(aTypes))
{
if (nCurrent > style::NumberingType::CHARS_LOWER_LETTER_N)
{
diff --git a/sw/source/uibase/uno/unodispatch.cxx b/sw/source/uibase/uno/unodispatch.cxx
index d185f982ccfc..e21810038ccc 100644
--- a/sw/source/uibase/uno/unodispatch.cxx
+++ b/sw/source/uibase/uno/unodispatch.cxx
@@ -105,7 +105,7 @@ uno::Sequence< uno::Reference< frame::XDispatch > > SwXDispatchProviderIntercept
{
DispatchMutexLock_Impl aLock;
uno::Sequence< uno::Reference< frame::XDispatch> > aReturn(aDescripts.getLength());
- std::transform(aDescripts.begin(), aDescripts.end(), aReturn.begin(),
+ std::transform(aDescripts.begin(), aDescripts.end(), aReturn.getArray(),
[this](const frame::DispatchDescriptor& rDescr) -> uno::Reference<frame::XDispatch> {
return queryDispatch(rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags); });
return aReturn;
diff --git a/sw/source/uibase/uno/unomodule.cxx b/sw/source/uibase/uno/unomodule.cxx
index a64f1951e0f5..da821aece71a 100644
--- a/sw/source/uibase/uno/unomodule.cxx
+++ b/sw/source/uibase/uno/unomodule.cxx
@@ -107,7 +107,7 @@ uno::Sequence< uno::Reference< frame::XDispatch > > SAL_CALL SwUnoModule::queryD
sal_Int32 nCount = seqDescripts.getLength();
uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount );
- std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.begin(),
+ std::transform(seqDescripts.begin(), seqDescripts.end(), lDispatcher.getArray(),
[this](const frame::DispatchDescriptor& rDescr) -> uno::Reference< frame::XDispatch > {
return queryDispatch( rDescr.FeatureURL, rDescr.FrameName, rDescr.SearchFlags ); });
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 2f2189456f3e..f74d07f0398c 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -2210,7 +2210,7 @@ Sequence< PropertyState > SAL_CALL SwXTextDocument::getPropertyStates( const Seq
const sal_Int32 nCount = rPropertyNames.getLength();
Sequence < PropertyState > aRet ( nCount );
- std::transform(rPropertyNames.begin(), rPropertyNames.end(), aRet.begin(),
+ std::transform(rPropertyNames.begin(), rPropertyNames.end(), aRet.getArray(),
[this](const OUString& rName) -> PropertyState { return getPropertyState(rName); });
return aRet;
@@ -4103,7 +4103,7 @@ Sequence< OUString > SwXLinkNameAccessWrapper::getElementNames()
{
const Sequence< OUString > aOrg = m_xRealAccess->getElementNames();
aRet.realloc(aOrg.getLength());
- std::transform(aOrg.begin(), aOrg.end(), aRet.begin(),
+ std::transform(aOrg.begin(), aOrg.end(), aRet.getArray(),
[this](const OUString& rOrg) -> OUString { return rOrg + m_sLinkSuffix; });
}
return aRet;