diff options
author | Noel Grandin <noel@peralex.com> | 2016-04-28 10:24:35 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-04-28 09:31:29 +0000 |
commit | 91adb929d747ef1434fb1732fdbf51283fda78e8 (patch) | |
tree | 928b7d95ab0cb21d8a887f1f6b47d6af261f0d12 /i18npool | |
parent | 43b4903db3e925c652e25c34362490f8adc9c5ec (diff) |
clang-tidy modernize-loop-convert in h-l/*
Change-Id: I843528327b25d18476f8959cabba16371213a48a
Reviewed-on: https://gerrit.libreoffice.org/24460
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'i18npool')
9 files changed, 49 insertions, 52 deletions
diff --git a/i18npool/source/breakiterator/breakiteratorImpl.cxx b/i18npool/source/breakiterator/breakiteratorImpl.cxx index 7fa79cf62696..33ac5864a79c 100644 --- a/i18npool/source/breakiterator/breakiteratorImpl.cxx +++ b/i18npool/source/breakiterator/breakiteratorImpl.cxx @@ -39,8 +39,8 @@ BreakIteratorImpl::BreakIteratorImpl() BreakIteratorImpl::~BreakIteratorImpl() { // Clear lookuptable - for (size_t l = 0; l < lookupTable.size(); l++) - delete lookupTable[l]; + for (lookupTableItem* p : lookupTable) + delete p; lookupTable.clear(); } @@ -526,8 +526,7 @@ sal_Int16 BreakIteratorImpl::getScriptClass(sal_uInt32 currentChar) bool SAL_CALL BreakIteratorImpl::createLocaleSpecificBreakIterator(const OUString& aLocaleName) throw( RuntimeException ) { // to share service between same Language but different Country code, like zh_CN and zh_TW - for (size_t l = 0; l < lookupTable.size(); l++) { - lookupTableItem *listItem = lookupTable[l]; + for (lookupTableItem* listItem : lookupTable) { if (aLocaleName == listItem->aLocale.Language) { xBI = listItem->xBI; return true; @@ -555,8 +554,7 @@ BreakIteratorImpl::getLocaleSpecificBreakIterator(const Locale& rLocale) throw ( else if (m_xContext.is()) { aLocale = rLocale; - for (size_t i = 0; i < lookupTable.size(); i++) { - lookupTableItem *listItem = lookupTable[i]; + for (lookupTableItem* listItem : lookupTable) { if (rLocale == listItem->aLocale) return xBI = listItem->xBI; } diff --git a/i18npool/source/breakiterator/breakiterator_unicode.cxx b/i18npool/source/breakiterator/breakiterator_unicode.cxx index f061d11001e5..8707dd452b83 100644 --- a/i18npool/source/breakiterator/breakiterator_unicode.cxx +++ b/i18npool/source/breakiterator/breakiterator_unicode.cxx @@ -52,8 +52,8 @@ BreakIterator_Unicode::~BreakIterator_Unicode() delete character.aBreakIterator; delete sentence.aBreakIterator; delete line.aBreakIterator; - for (size_t i = 0; i < SAL_N_ELEMENTS(words); i++) - delete words[i].aBreakIterator; + for (BI_Data & word : words) + delete word.aBreakIterator; } /* diff --git a/i18npool/source/breakiterator/xdictionary.cxx b/i18npool/source/breakiterator/xdictionary.cxx index 536b67e3edb8..551ce859592b 100644 --- a/i18npool/source/breakiterator/xdictionary.cxx +++ b/i18npool/source/breakiterator/xdictionary.cxx @@ -115,18 +115,18 @@ xdictionary::xdictionary(const sal_Char *lang) : #endif - for (sal_Int32 i = 0; i < CACHE_MAX; i++) - cache[i].size = 0; + for (WordBreakCache & i : cache) + i.size = 0; japaneseWordBreak = false; } xdictionary::~xdictionary() { - for (sal_Int32 i = 0; i < CACHE_MAX; i++) { - if (cache[i].size > 0) { - delete [] cache[i].contents; - delete [] cache[i].wordboundary; + for (WordBreakCache & i : cache) { + if (i.size > 0) { + delete [] i.contents; + delete [] i.wordboundary; } } } @@ -147,11 +147,11 @@ void xdictionary::initDictionaryData(const sal_Char *pLang) static std::vector< datacache > aLoadedCache; osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ); - for( size_t i = 0; i < aLoadedCache.size(); ++i ) + for(datacache & i : aLoadedCache) { - if( !strcmp( pLang, aLoadedCache[ i ].maLang.getStr() ) ) + if( !strcmp( pLang, i.maLang.getStr() ) ) { - data = aLoadedCache[ i ].maData; + data = i.maData; return; } } diff --git a/i18npool/source/calendar/calendarImpl.cxx b/i18npool/source/calendar/calendarImpl.cxx index 67a82dbb7795..48c4ad2d02a3 100644 --- a/i18npool/source/calendar/calendarImpl.cxx +++ b/i18npool/source/calendar/calendarImpl.cxx @@ -36,8 +36,8 @@ CalendarImpl::CalendarImpl(const Reference< XComponentContext > &rxContext) : m_ CalendarImpl::~CalendarImpl() { // Clear lookuptable - for (size_t l = 0; l < lookupTable.size(); l++) - delete lookupTable[l]; + for (lookupTableItem* p : lookupTable) + delete p; lookupTable.clear(); } diff --git a/i18npool/source/characterclassification/characterclassificationImpl.cxx b/i18npool/source/characterclassification/characterclassificationImpl.cxx index be40da7fb53f..41aa591bb148 100644 --- a/i18npool/source/characterclassification/characterclassificationImpl.cxx +++ b/i18npool/source/characterclassification/characterclassificationImpl.cxx @@ -36,8 +36,8 @@ CharacterClassificationImpl::CharacterClassificationImpl( CharacterClassificationImpl::~CharacterClassificationImpl() { // Clear lookuptable - for (size_t l = 0; l < lookupTable.size(); l++) - delete lookupTable[l]; + for (lookupTableItem* p : lookupTable) + delete p; lookupTable.clear(); } @@ -160,8 +160,8 @@ CharacterClassificationImpl::getLocaleSpecificCharacterClassification(const Loca if (cachedItem && cachedItem->equals(rLocale)) return cachedItem->xCI; else { - for (size_t i = 0; i < lookupTable.size(); i++) { - cachedItem = lookupTable[i]; + for (lookupTableItem* i : lookupTable) { + cachedItem = i; if (cachedItem->equals(rLocale)) return cachedItem->xCI; } diff --git a/i18npool/source/collator/collatorImpl.cxx b/i18npool/source/collator/collatorImpl.cxx index 874e3469f1f0..8b4919a68400 100644 --- a/i18npool/source/collator/collatorImpl.cxx +++ b/i18npool/source/collator/collatorImpl.cxx @@ -40,8 +40,8 @@ CollatorImpl::CollatorImpl( const Reference < XComponentContext >& rxContext ) : CollatorImpl::~CollatorImpl() { // Clear lookuptable - for (size_t l = 0; l < lookupTable.size(); l++) - delete lookupTable[l]; + for (lookupTableItem* p : lookupTable) + delete p; lookupTable.clear(); } @@ -170,8 +170,8 @@ void SAL_CALL CollatorImpl::loadCachedCollator(const lang::Locale& rLocale, const OUString& rSortAlgorithm) throw(RuntimeException) { - for (size_t i = 0; i < lookupTable.size(); i++) { - cachedItem = lookupTable[i]; + for (lookupTableItem* i : lookupTable) { + cachedItem = i; if (cachedItem->equals(rLocale, rSortAlgorithm)) { return; } diff --git a/i18npool/source/inputchecker/inputsequencechecker.cxx b/i18npool/source/inputchecker/inputsequencechecker.cxx index b1e71c125910..69c8525985af 100644 --- a/i18npool/source/inputchecker/inputsequencechecker.cxx +++ b/i18npool/source/inputchecker/inputsequencechecker.cxx @@ -43,8 +43,8 @@ InputSequenceCheckerImpl::InputSequenceCheckerImpl(const char *pServiceName) InputSequenceCheckerImpl::~InputSequenceCheckerImpl() { // Clear lookuptable - for (size_t l = 0; l < lookupTable.size(); l++) - delete lookupTable[l]; + for (lookupTableItem* p : lookupTable) + delete p; lookupTable.clear(); } @@ -111,8 +111,8 @@ InputSequenceCheckerImpl::getInputSequenceChecker(sal_Char* rLanguage) throw (Ru return cachedItem->xISC; } else { - for (size_t l = 0; l < lookupTable.size(); l++) { - cachedItem = lookupTable[l]; + for (lookupTableItem* l : lookupTable) { + cachedItem = l; if (cachedItem->aLanguage == rLanguage) return cachedItem->xISC; } diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index d8f5ed09371a..bfb59aac8864 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -484,26 +484,25 @@ oslGenericFunction SAL_CALL lcl_LookupTableHelper::getFunctionSymbolByName( aFallback = LocaleDataImpl::getFirstLocaleServiceName( aFbLocale); } - for ( sal_Int16 i = 0; i < nbOfLocales; i++) + for (const auto & i : aLibTable) { - if (localeName.equalsAscii(aLibTable[i].pLocale) || - (bFallback && aFallback.equalsAscii(aLibTable[i].pLocale))) + if (localeName.equalsAscii(i.pLocale) || + (bFallback && aFallback.equalsAscii(i.pLocale))) { #ifndef DISABLE_DYNLOADING OUStringBuffer aBuf(sal::static_int_cast<int>( - strlen(aLibTable[i].pLocale) + 1 + strlen(pFunction))); + strlen(i.pLocale) + 1 + strlen(pFunction))); { ::osl::MutexGuard aGuard( maMutex ); - for (size_t l = 0; l < maLookupTable.size(); l++) + for (LocaleDataLookupTableItem* pCurrent : maLookupTable) { - LocaleDataLookupTableItem* pCurrent = maLookupTable[l]; - if (pCurrent->dllName == aLibTable[i].pLib) + if (pCurrent->dllName == i.pLib) { OSL_ASSERT( pOutCachedItem ); if( pOutCachedItem ) { (*pOutCachedItem) = new LocaleDataLookupTableItem( *pCurrent ); - (*pOutCachedItem)->localeName = aLibTable[i].pLocale; + (*pOutCachedItem)->localeName = i.pLocale; return (*pOutCachedItem)->module->getFunctionSymbol( aBuf.appendAscii( pFunction).append( cUnder). appendAscii( (*pOutCachedItem)->localeName).makeStringAndClear()); @@ -515,17 +514,17 @@ oslGenericFunction SAL_CALL lcl_LookupTableHelper::getFunctionSymbolByName( } // Library not loaded, load it and add it to the list. #ifdef SAL_DLLPREFIX - aBuf.ensureCapacity(strlen(aLibTable[i].pLib) + 6); // mostly "lib*.so" - aBuf.append( SAL_DLLPREFIX ).appendAscii(aLibTable[i].pLib).append( SAL_DLLEXTENSION ); + aBuf.ensureCapacity(strlen(i.pLib) + 6); // mostly "lib*.so" + aBuf.append( SAL_DLLPREFIX ).appendAscii(i.pLib).append( SAL_DLLEXTENSION ); #else - aBuf.ensureCapacity(strlen(aLibTable[i].pLib) + 4); // mostly "*.dll" - aBuf.appendAscii(aLibTable[i].pLib).appendAscii( SAL_DLLEXTENSION ); + aBuf.ensureCapacity(strlen(i.pLib) + 4); // mostly "*.dll" + aBuf.appendAscii(i.pLib).appendAscii( SAL_DLLEXTENSION ); #endif osl::Module *module = new osl::Module(); if ( module->loadRelative(&thisModule, aBuf.makeStringAndClear()) ) { ::osl::MutexGuard aGuard( maMutex ); - LocaleDataLookupTableItem* pNewItem = new LocaleDataLookupTableItem(aLibTable[i].pLib, module, aLibTable[i].pLocale); + LocaleDataLookupTableItem* pNewItem = new LocaleDataLookupTableItem(i.pLib, module, i.pLocale); maLookupTable.push_back(pNewItem); OSL_ASSERT( pOutCachedItem ); if( pOutCachedItem ) @@ -844,15 +843,15 @@ LocaleDataImpl::getAllFormats( const Locale& rLocale ) throw(RuntimeException, s Sequence< FormatElement > seq(formatCount); sal_Int32 f = 0; - for (int s = 0; s < SECTIONS; ++s) + for (FormatSection & s : section) { - sal_Unicode const * const * const formatArray = section[s].formatArray; + sal_Unicode const * const * const formatArray = s.formatArray; if ( formatArray ) { - for (int i = 0, nOff = 0; i < section[s].formatCount; ++i, nOff += 7, ++f) + for (int i = 0, nOff = 0; i < s.formatCount; ++i, nOff += 7, ++f) { FormatElement elem( - OUString(formatArray[nOff]).replaceAll(section[s].from, section[s].to), + OUString(formatArray[nOff]).replaceAll(s.from, s.to), formatArray[nOff + 1], formatArray[nOff + 2], formatArray[nOff + 3], @@ -1468,8 +1467,8 @@ LocaleDataImpl::getAllInstalledLocaleNames() throw(RuntimeException, std::except Sequence< lang::Locale > seq( nbOfLocales ); sal_Int16 nInstalled = 0; - for( sal_Int16 i=0; i<nbOfLocales; i++ ) { - OUString name = OUString::createFromAscii( aLibTable[i].pLocale ); + for(const auto & i : aLibTable) { + OUString name = OUString::createFromAscii( i.pLocale ); // Check if the locale is really available and not just in the table, // don't allow fall backs. diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx index 2d7b254acf4a..6aa76d67612d 100644 --- a/i18npool/source/nativenumber/nativenumbersupplier.cxx +++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx @@ -615,9 +615,9 @@ OUString SAL_CALL NativeNumberSupplierService::getNativeNumberString(const OUStr sal_Unicode SAL_CALL NativeNumberSupplierService::getNativeNumberChar( const sal_Unicode inChar, const Locale& rLocale, sal_Int16 nNativeNumberMode ) throw(css::uno::RuntimeException) { if (nNativeNumberMode == NativeNumberMode::NATNUM0) { // Ascii - for (sal_Int16 i = 0; i < NumberChar_Count; i++) + for (const auto & i : NumberChar) for (sal_Int16 j = 0; j < 10; j++) - if (inChar == NumberChar[i][j]) + if (inChar == i[j]) return j; return inChar; } |