From 1e084caf573255a93ce86053d584976f317074df Mon Sep 17 00:00:00 2001 From: Arkadiy Illarionov Date: Thu, 27 Jun 2019 23:29:01 +0300 Subject: Simplify Sequence iterations in unotools Use range-based loops or replace with STL functions Change-Id: I220c5cd5dcc19fc35e1ad729ae69246f4a79ce2d Reviewed-on: https://gerrit.libreoffice.org/74825 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov --- unotools/source/config/lingucfg.cxx | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'unotools/source/config/lingucfg.cxx') diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx index a1c07d61489c..1d62a2f3013e 100644 --- a/unotools/source/config/lingucfg.cxx +++ b/unotools/source/config/lingucfg.cxx @@ -970,9 +970,8 @@ bool SvtLinguConfig::GetDictionaryEntry( if (bSuccess) { // get file URL's for the locations - for (sal_Int32 i = 0; i < aLocations.getLength(); ++i) + for (OUString& rLocation : aLocations) { - OUString &rLocation = aLocations[i]; if (!lcl_GetFileUrlFromOrigin( rLocation, rLocation )) bSuccess = false; } @@ -1018,33 +1017,27 @@ std::vector< SvtLinguConfigDictionaryEntry > SvtLinguConfig::GetActiveDictionari { uno::Sequence< OUString > aElementNames; GetElementNamesFor( aG_Dictionaries, aElementNames ); - sal_Int32 nLen = aElementNames.getLength(); - const OUString *pElementNames = aElementNames.getConstArray(); const uno::Sequence< OUString > aDisabledDics( GetDisabledDictionaries() ); SvtLinguConfigDictionaryEntry aDicEntry; - for (sal_Int32 i = 0; i < nLen; ++i) + for (const OUString& rElementName : aElementNames) { // does dictionary match the format we are looking for? - if (GetDictionaryEntry( pElementNames[i], aDicEntry ) && + if (GetDictionaryEntry( rElementName, aDicEntry ) && aDicEntry.aFormatName == rFormatName) { // check if it is active or not - bool bDicIsActive = true; - for (sal_Int32 k = 0; bDicIsActive && k < aDisabledDics.getLength(); ++k) - { - if (aDisabledDics[k] == pElementNames[i]) - bDicIsActive = false; - } + bool bDicIsActive = std::none_of(aDisabledDics.begin(), aDisabledDics.end(), + [&rElementName](const OUString& rDic) { return rDic == rElementName; }); if (bDicIsActive) { DBG_ASSERT( !aDicEntry.aFormatName.isEmpty(), "FormatName not set" ); - DBG_ASSERT( aDicEntry.aLocations.getLength(), + DBG_ASSERT( aDicEntry.aLocations.hasElements(), "Locations not set" ); - DBG_ASSERT( aDicEntry.aLocaleNames.getLength(), + DBG_ASSERT( aDicEntry.aLocaleNames.hasElements(), "Locales not set" ); aRes.push_back( aDicEntry ); } -- cgit