summaryrefslogtreecommitdiff
path: root/stoc
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 /stoc
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 'stoc')
-rw-r--r--stoc/source/implementationregistration/implreg.cxx14
-rw-r--r--stoc/source/invocation/invocation.cxx2
-rw-r--r--stoc/source/servicemanager/servicemanager.cxx2
3 files changed, 10 insertions, 8 deletions
diff --git a/stoc/source/implementationregistration/implreg.cxx b/stoc/source/implementationregistration/implreg.cxx
index bfd19ccd07e4..912ed434d29e 100644
--- a/stoc/source/implementationregistration/implreg.cxx
+++ b/stoc/source/implementationregistration/implreg.cxx
@@ -291,17 +291,19 @@ void createUniqueSubEntry(const Reference < XRegistryKey > & xSuperKey,
if (bReady)
{
Sequence<OUString> implEntriesNew(length);
- implEntriesNew.getArray()[0] = value;
+ auto it = implEntriesNew.getArray();
+ *it = value;
- std::copy_if(implEntries.begin(), implEntries.end(), std::next(implEntriesNew.begin()),
+ std::copy_if(implEntries.begin(), implEntries.end(), std::next(it),
[&value](const OUString& rEntry) { return rEntry != value; });
xSuperKey->setAsciiListValue(implEntriesNew);
} else
{
Sequence<OUString> implEntriesNew(length+1);
- implEntriesNew.getArray()[0] = value;
+ auto it = implEntriesNew.getArray();
+ *it = value;
- std::copy(implEntries.begin(), implEntries.end(), std::next(implEntriesNew.begin()));
+ std::copy(implEntries.begin(), implEntries.end(), std::next(it));
xSuperKey->setAsciiListValue(implEntriesNew);
}
} else
@@ -332,7 +334,7 @@ bool deleteSubEntry(const Reference < XRegistryKey >& xSuperKey, const OUString&
{
Sequence<OUString> implEntriesNew(length - equals);
- std::copy_if(implEntries.begin(), implEntries.end(), implEntriesNew.begin(),
+ std::copy_if(implEntries.begin(), implEntries.end(), implEntriesNew.getArray(),
[&value](const OUString& rEntry) { return rEntry != value; });
xSuperKey->setAsciiListValue(implEntriesNew);
}
@@ -741,7 +743,7 @@ void deleteAllServiceEntries( const Reference < XSimpleRegistry >& xReg,
{
Sequence<OUString> implEntriesNew(length-equals);
- std::copy_if(implEntries.begin(), implEntries.end(), implEntriesNew.begin(),
+ std::copy_if(implEntries.begin(), implEntries.end(), implEntriesNew.getArray(),
[&implName](const OUString& rEntry) { return rEntry != implName; });
xServiceKey->setAsciiListValue(implEntriesNew);
diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx
index 6d4db16effe3..ab8a10fa1ef6 100644
--- a/stoc/source/invocation/invocation.cxx
+++ b/stoc/source/invocation/invocation.cxx
@@ -669,7 +669,7 @@ Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>&
OutIndices.realloc( nOutIndex );
OutParams.realloc( nOutIndex );
- std::transform(std::cbegin(OutIndices), std::cend(OutIndices), OutParams.begin(),
+ std::transform(std::cbegin(OutIndices), std::cend(OutIndices), OutParams.getArray(),
[&pInvokeParams](const sal_Int16 nIndex) -> Any { return pInvokeParams[nIndex]; });
return aRet;
diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx
index 3e50aed3953a..82f0335a0808 100644
--- a/stoc/source/servicemanager/servicemanager.cxx
+++ b/stoc/source/servicemanager/servicemanager.cxx
@@ -89,7 +89,7 @@ Sequence< OUString > retrieveAsciiValueList(
sal_Int32 n2Len = seq2.getLength();
seq.realloc( n1Len + n2Len );
- std::copy(seq2.begin(), seq2.end(), std::next(seq.begin(), n1Len));
+ std::copy(seq2.begin(), seq2.end(), std::next(seq.getArray(), n1Len));
}
}
}