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 /svl | |
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 'svl')
-rw-r--r-- | svl/qa/unit/lockfiles/test_lockfiles.cxx | 2 | ||||
-rw-r--r-- | svl/source/config/asiancfg.cxx | 2 | ||||
-rw-r--r-- | svl/source/misc/PasswordHelper.cxx | 4 | ||||
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 5 | ||||
-rw-r--r-- | svl/source/passwordcontainer/passwordcontainer.cxx | 2 |
5 files changed, 8 insertions, 7 deletions
diff --git a/svl/qa/unit/lockfiles/test_lockfiles.cxx b/svl/qa/unit/lockfiles/test_lockfiles.cxx index b2bba0f9ce3c..d66c301be4e7 100644 --- a/svl/qa/unit/lockfiles/test_lockfiles.cxx +++ b/svl/qa/unit/lockfiles/test_lockfiles.cxx @@ -81,7 +81,7 @@ OUString readLockFile(const OUString& aSource) std::unique_ptr<sal_Int8[]> pBuffer(new sal_Int8[nSize]); aFileStream.ReadBytes(pBuffer.get(), nSize); - css::uno::Sequence<sal_Int8> aData(pBuffer.get(), nSize); + const css::uno::Sequence<sal_Int8> aData(pBuffer.get(), nSize); OStringBuffer aResult(static_cast<int>(nSize)); for (sal_Int8 nByte : aData) { diff --git a/svl/source/config/asiancfg.cxx b/svl/source/config/asiancfg.cxx index 3e6affd8b83d..5f179447839d 100644 --- a/svl/source/config/asiancfg.cxx +++ b/svl/source/config/asiancfg.cxx @@ -103,7 +103,7 @@ css::uno::Sequence< css::lang::Locale > SvxAsianConfig::GetStartEndCharLocales() impl_->context)-> getElementNames()); css::uno::Sequence< css::lang::Locale > ls(ns.getLength()); - std::transform(ns.begin(), ns.end(), ls.begin(), + std::transform(ns.begin(), ns.end(), ls.getArray(), [](const OUString& rName) -> css::lang::Locale { return LanguageTag::convertToLocale( rName, false); }); return ls; diff --git a/svl/source/misc/PasswordHelper.cxx b/svl/source/misc/PasswordHelper.cxx index 617aeafdae1b..047d0b09b88b 100644 --- a/svl/source/misc/PasswordHelper.cxx +++ b/svl/source/misc/PasswordHelper.cxx @@ -32,7 +32,7 @@ void SvPasswordHelper::GetHashPasswordSHA256(uno::Sequence<sal_Int8>& rPassHash, reinterpret_cast<unsigned char const*>(tmp.getStr()), tmp.getLength(), ::comphelper::HashType::SHA256)); rPassHash.realloc(hash.size()); - ::std::copy(hash.begin(), hash.end(), rPassHash.begin()); + ::std::copy(hash.begin(), hash.end(), rPassHash.getArray()); rtl_secureZeroMemory(const_cast<char *>(tmp.getStr()), tmp.getLength()); } @@ -43,7 +43,7 @@ void SvPasswordHelper::GetHashPasswordSHA1UTF8(uno::Sequence<sal_Int8>& rPassHas reinterpret_cast<unsigned char const*>(tmp.getStr()), tmp.getLength(), ::comphelper::HashType::SHA1)); rPassHash.realloc(hash.size()); - ::std::copy(hash.begin(), hash.end(), rPassHash.begin()); + ::std::copy(hash.begin(), hash.end(), rPassHash.getArray()); rtl_secureZeroMemory(const_cast<char *>(tmp.getStr()), tmp.getLength()); } diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 6b385f4e7854..d2340bf2d968 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -3053,8 +3053,9 @@ void SvNumberFormatter::ImpGenerateAdditionalFormats( sal_uInt32 CLOffset, // ImpGenerateFormats for old "automatic" currency formats. uno::Sequence< i18n::NumberFormatCode > aFormatSeq = rNumberFormatCode->getAllFormatCode( i18n::KNumberFormatUsage::CURRENCY, aLocale ); sal_Int32 nCodes = aFormatSeq.getLength(); - ImpAdjustFormatCodeDefault( aFormatSeq.getArray(), nCodes ); - for ( i18n::NumberFormatCode& rFormat : aFormatSeq ) + auto aNonConstRange = asNonConstRange(aFormatSeq); + ImpAdjustFormatCodeDefault( aNonConstRange.begin(), nCodes); + for ( i18n::NumberFormatCode& rFormat : aNonConstRange ) { if ( nPos - CLOffset >= SV_COUNTRY_LANGUAGE_OFFSET ) { diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx index c483a78b75cd..a5621e0ee4b2 100644 --- a/svl/source/passwordcontainer/passwordcontainer.cxx +++ b/svl/source/passwordcontainer/passwordcontainer.cxx @@ -186,7 +186,7 @@ PasswordMap StorageItem::getInfo() sal_Int32 aNodeCount = aNodeNames.getLength(); Sequence< OUString > aPropNames( aNodeCount ); - std::transform(aNodeNames.begin(), aNodeNames.end(), aPropNames.begin(), + std::transform(aNodeNames.begin(), aNodeNames.end(), aPropNames.getArray(), [](const OUString& rName) -> OUString { return "Store/Passwordstorage['" + rName + "']/Password"; }); |