diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-08-29 00:51:02 +0300 |
---|---|---|
committer | Arkadiy Illarionov <qarkai@gmail.com> | 2019-08-30 14:15:57 +0200 |
commit | 760a377f7148e623e9e16d24e66f54a401ecb946 (patch) | |
tree | c9ea106618e4b9f6bb2c20d8817603c7556a9ef6 /linguistic/source/hyphdsp.cxx | |
parent | cc4edc0f29c034722f10ab289eb0d8d563a8632c (diff) |
Simplify Sequence iterations in lingucomponent..lotuswordpro
Use range-based loops, STL and comphelper functions.
Change-Id: I975a9c09265976d5ce4a1d7ac2023cbb75bb7f28
Reviewed-on: https://gerrit.libreoffice.org/78242
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'linguistic/source/hyphdsp.cxx')
-rw-r--r-- | linguistic/source/hyphdsp.cxx | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/linguistic/source/hyphdsp.cxx b/linguistic/source/hyphdsp.cxx index fa0a77ff20a5..f2665b653561 100644 --- a/linguistic/source/hyphdsp.cxx +++ b/linguistic/source/hyphdsp.cxx @@ -33,6 +33,7 @@ #include <tools/debug.hxx> #include <svl/lngmisc.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/sequence.hxx> #include <osl/mutex.hxx> #include "hyphdsp.hxx" @@ -251,13 +252,13 @@ Sequence< Locale > SAL_CALL HyphenatorDispatcher::getLocales() { MutexGuard aGuard( GetLinguMutex() ); - Sequence< Locale > aLocales( static_cast< sal_Int32 >(aSvcMap.size()) ); - Locale *pLocales = aLocales.getArray(); - for (auto const& elem : aSvcMap) - { - *pLocales++ = LanguageTag::convertToLocale(elem.first); - } - return aLocales; + std::vector<Locale> aLocales; + aLocales.reserve(aSvcMap.size()); + + std::transform(aSvcMap.begin(), aSvcMap.end(), std::back_inserter(aLocales), + [](HyphSvcByLangMap_t::const_reference elem) { return LanguageTag::convertToLocale(elem.first); }); + + return comphelper::containerToSequence(aLocales); } @@ -661,8 +662,7 @@ void HyphenatorDispatcher::SetServiceList( const Locale &rLocale, LanguageType nLanguage = LinguLocaleToLanguage( rLocale ); - sal_Int32 nLen = rSvcImplNames.getLength(); - if (0 == nLen) + if (!rSvcImplNames.hasElements()) // remove entry aSvcMap.erase( nLanguage ); else |