From 966f40eecfc60f20c309bc2477149442d753763a Mon Sep 17 00:00:00 2001 From: Arkadiy Illarionov Date: Sat, 4 May 2019 17:06:38 +0300 Subject: Use hasElements to check Sequence emptiness in [e-i]* Similar to clang-tidy readability-container-size-empty Change-Id: I79e31919db8f4132216f09a7868d18835eeb154b Reviewed-on: https://gerrit.libreoffice.org/71795 Tested-by: Jenkins Reviewed-by: Noel Grandin --- i18npool/source/indexentry/indexentrysupplier.cxx | 2 +- i18npool/source/indexentry/indexentrysupplier_default.cxx | 4 ++-- i18npool/source/localedata/localedata.cxx | 2 +- i18npool/source/textconversion/textconversion_zh.cxx | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'i18npool') diff --git a/i18npool/source/indexentry/indexentrysupplier.cxx b/i18npool/source/indexentry/indexentrysupplier.cxx index 5bf55607ab5d..3660c89e6e46 100644 --- a/i18npool/source/indexentry/indexentrysupplier.cxx +++ b/i18npool/source/indexentry/indexentrysupplier.cxx @@ -166,7 +166,7 @@ OUString SAL_CALL IndexEntrySupplier::getIndexFollowPageWord( sal_Bool bMorePage Sequence< OUString > aFollowPageWords = LocaleDataImpl::get()->getFollowPageWords(rLocale); return (bMorePages && aFollowPageWords.getLength() > 1) ? - aFollowPageWords[1] : (aFollowPageWords.getLength() > 0 ? + aFollowPageWords[1] : (aFollowPageWords.hasElements() ? aFollowPageWords[0] : OUString()); } diff --git a/i18npool/source/indexentry/indexentrysupplier_default.cxx b/i18npool/source/indexentry/indexentrysupplier_default.cxx index 2dc123822e07..186f3a511f59 100644 --- a/i18npool/source/indexentry/indexentrysupplier_default.cxx +++ b/i18npool/source/indexentry/indexentrysupplier_default.cxx @@ -258,9 +258,9 @@ void Index::init(const lang::Locale &rLocale, const OUString& algorithm) Sequence< UnicodeScript > scriptList = LocaleDataImpl::get()->getUnicodeScripts( rLocale ); - if (scriptList.getLength() == 0) { + if (!scriptList.hasElements()) { scriptList = LocaleDataImpl::get()->getUnicodeScripts(LOCALE_EN); - if (scriptList.getLength() == 0) + if (!scriptList.hasElements()) throw RuntimeException(); } diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index 454c4045ddef..91808eebdb77 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -673,7 +673,7 @@ Sequence< CalendarItem2 > &LocaleDataImpl::getCalendarItemByName(const OUString& // Referred locale not found, return name for en_US locale. if (index == cals.getLength()) { cals = getAllCalendars2( Locale("en", "US", OUString()) ); - if (cals.getLength() <= 0) + if (!cals.hasElements()) throw RuntimeException(); ref_cal = cals[0]; } diff --git a/i18npool/source/textconversion/textconversion_zh.cxx b/i18npool/source/textconversion/textconversion_zh.cxx index c9ca672edd3d..3f7ff96d8a15 100644 --- a/i18npool/source/textconversion/textconversion_zh.cxx +++ b/i18npool/source/textconversion/textconversion_zh.cxx @@ -193,8 +193,8 @@ TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos, // catch all other exceptions to allow // querying the system dictionary in the next line } - if (conversions.getLength() > 0) { - if (offset.getLength() > 0) { + if (conversions.hasElements()) { + if (offset.hasElements()) { if (word.getLength() != conversions[0].getLength()) one2one=false; while (current < conversions[0].getLength()) { @@ -229,7 +229,7 @@ TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos, else // Simplified/Traditionary conversion, forwards search for next word current = entry[current] + word.getLength() + 1; sal_Int32 start=current; - if (offset.getLength() > 0) { + if (offset.hasElements()) { if (word.getLength() != OUString(&wordData[current]).getLength()) one2one=false; sal_Int32 convertedLength=OUString(&wordData[current]).getLength(); @@ -250,14 +250,14 @@ TextConversion_zh::getWordConversion(const OUString& aText, sal_Int32 nStartPos, } } if (!found) { - if (offset.getLength() > 0) + if (offset.hasElements()) offset[count]=nStartPos+currPos; newStr[count++] = getOneCharConversion(aText[nStartPos+currPos], charData, charIndex); currPos++; } } - if (offset.getLength() > 0) + if (offset.hasElements()) offset.realloc(one2one ? 0 : count); OUString aRet(newStr.get(), count); return aRet; -- cgit