[Libreoffice-commits] core.git: i18npool/source

Mike Kaganski mike.kaganski at collabora.com
Wed Dec 20 06:57:08 UTC 2017


 i18npool/source/localedata/localedata.cxx                |   35 ++++++---------
 i18npool/source/nativenumber/nativenumbersupplier.cxx    |    4 -
 i18npool/source/transliteration/ignoreDiacritics_CTL.cxx |    5 +-
 3 files changed, 19 insertions(+), 25 deletions(-)

New commits:
commit 4e124b17a71d24079f43da68fb239b2e2a29dc4e
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Wed Dec 20 05:43:19 2017 +0200

    loplugin:unusedindex
    
    Change-Id: Id6e17d00c87d79f899cf691d00e600dfc102cab0
    Reviewed-on: https://gerrit.libreoffice.org/46832
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx
index 9d67a151fed2..6347b9a54353 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -352,12 +352,10 @@ namespace i18npool {
 // static
 Sequence< CalendarItem > LocaleDataImpl::downcastCalendarItems( const Sequence< CalendarItem2 > & rCi )
 {
-    sal_Int32 nSize = rCi.getLength();
-    Sequence< CalendarItem > aCi( nSize);
+    Sequence< CalendarItem > aCi(rCi.getLength());
     CalendarItem* p1 = aCi.getArray();
-    const CalendarItem2* p2 = rCi.getConstArray();
-    for (sal_Int32 i=0; i < nSize; ++i, ++p1, ++p2)
-        *p1 = *p2;
+    for (const CalendarItem2& r2 : rCi)
+        *p1++ = r2;
     return aCi;
 }
 
@@ -712,30 +710,29 @@ Sequence< CalendarItem2 > LocaleDataImpl::getCalendarItems(
     }
     else
     {
-        sal_Int32 nSize = allCalendars[nWhichItem][nCalendar];
+        const sal_Int32 nSize = allCalendars[nWhichItem][nCalendar];
         aItems.realloc( nSize);
-        CalendarItem2* pItem = aItems.getArray();
         switch (nWhichItem)
         {
             case REF_DAYS:
             case REF_MONTHS:
             case REF_GMONTHS:
             case REF_PMONTHS:
-                for (sal_Int32 j = 0; j < nSize; ++j, ++pItem)
+                for (CalendarItem2& rItem : aItems)
                 {
                     CalendarItem2 item( allCalendars[rnOffset], allCalendars[rnOffset+1],
                             allCalendars[rnOffset+2], allCalendars[rnOffset+3]);
-                    *pItem = item;
+                    rItem = item;
                     rnOffset += 4;
                 }
                 break;
             case REF_ERAS:
                 // Absent narrow name.
-                for (sal_Int32 j = 0; j < nSize; ++j, ++pItem)
+                for (CalendarItem2& rItem : aItems)
                 {
                     CalendarItem2 item( allCalendars[rnOffset], allCalendars[rnOffset+1],
                             allCalendars[rnOffset+2], OUString());
-                    *pItem = item;
+                    rItem = item;
                     rnOffset += 3;
                 }
                 break;
@@ -796,13 +793,11 @@ Sequence< Calendar > SAL_CALL
 LocaleDataImpl::getAllCalendars( const Locale& rLocale )
 {
     const Sequence< Calendar2 > aCal2( getAllCalendars2( rLocale));
-    sal_Int32 nLen = aCal2.getLength();
-    Sequence< Calendar > aCal1( nLen);
-    const Calendar2* p2 = aCal2.getConstArray();
+    Sequence< Calendar > aCal1( aCal2.getLength());
     Calendar* p1 = aCal1.getArray();
-    for (sal_Int32 i=0; i < nLen; ++i, ++p1, ++p2)
+    for (const Calendar2& r2 : aCal2)
     {
-        *p1 = downcastCalendar( *p2);
+        *p1++ = downcastCalendar( r2);
     }
     return aCal1;
 }
@@ -844,13 +839,11 @@ Sequence< Currency > SAL_CALL
 LocaleDataImpl::getAllCurrencies( const Locale& rLocale )
 {
     Sequence< Currency2 > aCur2( getAllCurrencies2( rLocale));
-    sal_Int32 nLen = aCur2.getLength();
-    Sequence< Currency > aCur1( nLen);
-    const Currency2* p2 = aCur2.getArray();
+    Sequence< Currency > aCur1( aCur2.getLength());
     Currency* p1 = aCur1.getArray();
-    for (sal_Int32 i=0; i < nLen; ++i, ++p1, ++p2)
+    for (const Currency2& r2 : aCur2)
     {
-        *p1 = *p2;
+        *p1 = r2;
     }
     return aCur1;
 }
diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx
index 3c528e2f895e..cd8bfa25c905 100644
--- a/i18npool/source/nativenumber/nativenumbersupplier.cxx
+++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx
@@ -99,7 +99,7 @@ bool AsciiToNative_numberMaker(const sal_Unicode *str, sal_Int32 begin, sal_Int3
     if ( len <= number->multiplierExponent[number->exponentCount-1] ) {
         if (number->multiplierExponent[number->exponentCount-1] > 1) {
             bool bNotZero = false;
-            for (sal_Int32 i = 0; i < len; i++, begin++) {
+            for (const sal_Int32 end = begin+len; begin < end; begin++) {
                 if (bNotZero || str[begin] != NUMBER_ZERO) {
                     dst[count] = numberChar[str[begin] - NUMBER_ZERO];
                     if (useOffset)
@@ -278,7 +278,7 @@ static void NativeToAscii_numberMaker(sal_Int16 max, sal_Int16 prev, const sal_U
             }
             if (shift) {
                 count -= max;
-                for (sal_Int16 j = 0; j < shift; j++, count++) {
+                for (const sal_Int32 countEnd = count+shift; count < countEnd; count++) {
                     dst[count] = dst[count + curr];
                     if (useOffset)
                         offset[count] = offset[count + curr];
diff --git a/i18npool/source/transliteration/ignoreDiacritics_CTL.cxx b/i18npool/source/transliteration/ignoreDiacritics_CTL.cxx
index 2b5ca1ed1bdb..53cfc15790da 100644
--- a/i18npool/source/transliteration/ignoreDiacritics_CTL.cxx
+++ b/i18npool/source/transliteration/ignoreDiacritics_CTL.cxx
@@ -73,11 +73,12 @@ ignoreDiacritics_CTL::folding(const OUString& rInStr, sal_Int32 nStartPos,
 
             if (nOffset + aUStr.length() > rOffset.getLength())
                 rOffset.realloc(rOffset.getLength() + aUStr.length());
+            sal_Int32* pOffset = rOffset.getArray();
 
             aOutBuf.append(reinterpret_cast<const sal_Unicode*>(aUStr.getBuffer()), aUStr.length());
 
-            for (int32_t i = 0; i < aUStr.length(); i++)
-                rOffset[nOffset++] = nPosition;
+            for (const sal_Int32 nOffsetEnd = nOffset+aUStr.length(); nOffset < nOffsetEnd; nOffset++)
+                pOffset[nOffset] = nPosition;
 
             nPosition = nIndex;
         }


More information about the Libreoffice-commits mailing list