ICU-12410 remove locCache behavior from ucase_getCaseLocale() and functions that...
authorMarkus Scherer <markus.icu@gmail.com>
Fri, 20 Jan 2017 06:27:47 +0000 (06:27 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Fri, 20 Jan 2017 06:27:47 +0000 (06:27 +0000)
X-SVN-Rev: 39586

icu4c/source/common/ucase.cpp
icu4c/source/common/ucase.h
icu4c/source/common/ucasemap.cpp
icu4c/source/common/ucasemap_titlecase_brkiter.cpp
icu4c/source/common/uniset_closure.cpp
icu4c/source/common/ustr_imp.h
icu4c/source/common/ustr_titlecase_brkiter.cpp
icu4c/source/common/ustrcase.cpp
icu4c/source/common/ustrcase_locale.cpp
icu4c/source/i18n/casetrn.cpp
icu4c/source/i18n/titletrn.cpp

index 051c914da3170324a3b2b9a96b003cf87c4108de..8e2455fbe1ed2d5dbb89c6467e0e35c72cb0ed0a 100644 (file)
@@ -545,12 +545,10 @@ ucase_isCaseSensitive(const UCaseProps * /* unused csp */, UChar32 c) {
  *     zero or more case-ignorable characters.
  */
 
-#define is_a(c) ((c)=='a' || (c)=='A')
 #define is_d(c) ((c)=='d' || (c)=='D')
 #define is_e(c) ((c)=='e' || (c)=='E')
 #define is_i(c) ((c)=='i' || (c)=='I')
 #define is_l(c) ((c)=='l' || (c)=='L')
-#define is_n(c) ((c)=='n' || (c)=='N')
 #define is_r(c) ((c)=='r' || (c)=='R')
 #define is_t(c) ((c)=='t' || (c)=='T')
 #define is_u(c) ((c)=='u' || (c)=='U')
@@ -565,16 +563,7 @@ ucase_isCaseSensitive(const UCaseProps * /* unused csp */, UChar32 c) {
  * Accepts both 2- and 3-letter codes and accepts case variants.
  */
 U_CFUNC int32_t
-ucase_getCaseLocale(const char *locale, int32_t *locCache) {
-    int32_t result;
-    char c;
-
-    if(locCache!=NULL && (result=*locCache)!=UCASE_LOC_UNKNOWN) {
-        return result;
-    }
-
-    result=UCASE_LOC_ROOT;
-
+ucase_getCaseLocale(const char *locale) {
     /*
      * This function used to use uloc_getLanguage(), but the current code
      * removes the dependency of this low-level code on uloc implementation code
@@ -584,73 +573,149 @@ ucase_getCaseLocale(const char *locale, int32_t *locCache) {
      * Because this code does not want to depend on uloc, the caller must
      * pass in a non-NULL locale, i.e., may need to call uloc_getDefault().
      */
-    c=*locale++;
-    if(is_t(c)) {
-        /* tr or tur? */
+    char c=*locale++;
+    // Fastpath for English "en" which is often used for default (=root locale) case mappings,
+    // and for Chinese "zh": Very common but no special case mapping behavior.
+    // Then check lowercase vs. uppercase to reduce the number of comparisons
+    // for other locales without special behavior.
+    if(c=='e') {
+        /* el or ell? */
         c=*locale++;
-        if(is_u(c)) {
+        if(is_l(c)) {
             c=*locale++;
-        }
-        if(is_r(c)) {
-            c=*locale;
+            if(is_l(c)) {
+                c=*locale;
+            }
             if(is_sep(c)) {
-                result=UCASE_LOC_TURKISH;
+                return UCASE_LOC_GREEK;
             }
         }
-    } else if(is_a(c)) {
-        /* az or aze? */
-        c=*locale++;
-        if(is_z(c)) {
+        // en, es, ... -> root
+    } else if(c=='z') {
+        return UCASE_LOC_ROOT;
+#if U_CHARSET_FAMILY==U_ASCII_FAMILY
+    } else if(c>='a') {  // ASCII a-z = 0x61..0x7a, after A-Z
+#elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY
+    } else if(c<='z') {  // EBCDIC a-z = 0x81..0xa9 with two gaps, before A-Z
+#else
+#   error Unknown charset family!
+#endif
+        // lowercase c
+        if(c=='t') {
+            /* tr or tur? */
             c=*locale++;
-            if(is_e(c)) {
+            if(is_u(c)) {
+                c=*locale++;
+            }
+            if(is_r(c)) {
                 c=*locale;
+                if(is_sep(c)) {
+                    return UCASE_LOC_TURKISH;
+                }
             }
-            if(is_sep(c)) {
-                result=UCASE_LOC_TURKISH;
+        } else if(c=='a') {
+            /* az or aze? */
+            c=*locale++;
+            if(is_z(c)) {
+                c=*locale++;
+                if(is_e(c)) {
+                    c=*locale;
+                }
+                if(is_sep(c)) {
+                    return UCASE_LOC_TURKISH;
+                }
             }
-        }
-    } else if(is_l(c)) {
-        /* lt or lit? */
-        c=*locale++;
-        if(is_i(c)) {
+        } else if(c=='l') {
+            /* lt or lit? */
             c=*locale++;
-        }
-        if(is_t(c)) {
-            c=*locale;
-            if(is_sep(c)) {
-                result=UCASE_LOC_LITHUANIAN;
+            if(is_i(c)) {
+                c=*locale++;
             }
-        }
-    } else if(is_e(c)) {
-        /* el or ell? */
-        c=*locale++;
-        if(is_l(c)) {
+            if(is_t(c)) {
+                c=*locale;
+                if(is_sep(c)) {
+                    return UCASE_LOC_LITHUANIAN;
+                }
+            }
+        } else if(c=='n') {
+            /* nl or nld? */
             c=*locale++;
             if(is_l(c)) {
+                c=*locale++;
+                if(is_d(c)) {
+                    c=*locale;
+                }
+                if(is_sep(c)) {
+                    return UCASE_LOC_DUTCH;
+                }
+            }
+        }
+    } else {
+        // uppercase c
+        // Same code as for lowercase c but also check for 'E'.
+        if(c=='T') {
+            /* tr or tur? */
+            c=*locale++;
+            if(is_u(c)) {
+                c=*locale++;
+            }
+            if(is_r(c)) {
                 c=*locale;
+                if(is_sep(c)) {
+                    return UCASE_LOC_TURKISH;
+                }
             }
-            if(is_sep(c)) {
-                result=UCASE_LOC_GREEK;
+        } else if(c=='A') {
+            /* az or aze? */
+            c=*locale++;
+            if(is_z(c)) {
+                c=*locale++;
+                if(is_e(c)) {
+                    c=*locale;
+                }
+                if(is_sep(c)) {
+                    return UCASE_LOC_TURKISH;
+                }
             }
-        }
-    } else if(is_n(c)) {
-        /* nl or nld? */
-        c=*locale++;
-        if(is_l(c)) {
+        } else if(c=='L') {
+            /* lt or lit? */
             c=*locale++;
-            if(is_d(c)) {
+            if(is_i(c)) {
+                c=*locale++;
+            }
+            if(is_t(c)) {
                 c=*locale;
+                if(is_sep(c)) {
+                    return UCASE_LOC_LITHUANIAN;
+                }
             }
-            if(is_sep(c)) {
-                result=UCASE_LOC_DUTCH;
+        } else if(c=='E') {
+            /* el or ell? */
+            c=*locale++;
+            if(is_l(c)) {
+                c=*locale++;
+                if(is_l(c)) {
+                    c=*locale;
+                }
+                if(is_sep(c)) {
+                    return UCASE_LOC_GREEK;
+                }
+            }
+        } else if(c=='N') {
+            /* nl or nld? */
+            c=*locale++;
+            if(is_l(c)) {
+                c=*locale++;
+                if(is_d(c)) {
+                    c=*locale;
+                }
+                if(is_sep(c)) {
+                    return UCASE_LOC_DUTCH;
+                }
             }
         }
     }
-
-    if(locCache!=NULL) {
-        *locCache=result;
-    }
-    return result;
+    return UCASE_LOC_ROOT;
 }
 
 /*
@@ -815,7 +880,7 @@ U_CAPI int32_t U_EXPORT2
 ucase_toFullLower(const UCaseProps * /* unused csp */, UChar32 c,
                   UCaseContextIterator *iter, void *context,
                   const UChar **pString,
-                  const char *locale, int32_t *locCache) {
+                  int32_t loc) {
     // The sign of the result has meaning, input must be non-negative so that it can be returned as is.
     U_ASSERT(c >= 0);
     UChar32 result=c;
@@ -833,7 +898,6 @@ ucase_toFullLower(const UCaseProps * /* unused csp */, UChar32 c,
 
         if(excWord&UCASE_EXC_CONDITIONAL_SPECIAL) {
             /* use hardcoded conditions and mappings */
-            int32_t loc=ucase_getCaseLocale(locale, locCache);
 
             /*
              * Test for conditional mappings first
@@ -960,7 +1024,7 @@ static int32_t
 toUpperOrTitle(const UCaseProps * /* unused csp */, UChar32 c,
                UCaseContextIterator *iter, void *context,
                const UChar **pString,
-               const char *locale, int32_t *locCache,
+               int32_t loc,
                UBool upperNotTitle) {
     // The sign of the result has meaning, input must be non-negative so that it can be returned as is.
     U_ASSERT(c >= 0);
@@ -979,8 +1043,6 @@ toUpperOrTitle(const UCaseProps * /* unused csp */, UChar32 c,
 
         if(excWord&UCASE_EXC_CONDITIONAL_SPECIAL) {
             /* use hardcoded conditions and mappings */
-            int32_t loc=ucase_getCaseLocale(locale, locCache);
-
             if(loc==UCASE_LOC_TURKISH && c==0x69) {
                 /*
                     # Turkish and Azeri
@@ -1055,16 +1117,16 @@ U_CAPI int32_t U_EXPORT2
 ucase_toFullUpper(const UCaseProps * /* unused csp */, UChar32 c,
                   UCaseContextIterator *iter, void *context,
                   const UChar **pString,
-                  const char *locale, int32_t *locCache) {
-    return toUpperOrTitle(&ucase_props_singleton, c, iter, context, pString, locale, locCache, TRUE);
+                  int32_t caseLocale) {
+    return toUpperOrTitle(&ucase_props_singleton, c, iter, context, pString, caseLocale, TRUE);
 }
 
 U_CAPI int32_t U_EXPORT2
 ucase_toFullTitle(const UCaseProps * /* unused csp */, UChar32 c,
                   UCaseContextIterator *iter, void *context,
                   const UChar **pString,
-                  const char *locale, int32_t *locCache) {
-    return toUpperOrTitle(&ucase_props_singleton, c, iter, context, pString, locale, locCache, FALSE);
+                  int32_t caseLocale) {
+    return toUpperOrTitle(&ucase_props_singleton, c, iter, context, pString, caseLocale, FALSE);
 }
 
 /* case folding ------------------------------------------------------------- */
@@ -1286,7 +1348,6 @@ U_CFUNC int32_t U_EXPORT2
 ucase_hasBinaryProperty(UChar32 c, UProperty which) {
     /* case mapping properties */
     const UChar *resultString;
-    int32_t locCache;
     switch(which) {
     case UCHAR_LOWERCASE:
         return (UBool)(UCASE_LOWER==ucase_getType(&ucase_props_singleton, c));
@@ -1313,21 +1374,17 @@ ucase_hasBinaryProperty(UChar32 c, UProperty which) {
      * start sets for normalization and case mappings.
      */
     case UCHAR_CHANGES_WHEN_LOWERCASED:
-        locCache=UCASE_LOC_ROOT;
-        return (UBool)(ucase_toFullLower(&ucase_props_singleton, c, NULL, NULL, &resultString, "", &locCache)>=0);
+        return (UBool)(ucase_toFullLower(&ucase_props_singleton, c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0);
     case UCHAR_CHANGES_WHEN_UPPERCASED:
-        locCache=UCASE_LOC_ROOT;
-        return (UBool)(ucase_toFullUpper(&ucase_props_singleton, c, NULL, NULL, &resultString, "", &locCache)>=0);
+        return (UBool)(ucase_toFullUpper(&ucase_props_singleton, c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0);
     case UCHAR_CHANGES_WHEN_TITLECASED:
-        locCache=UCASE_LOC_ROOT;
-        return (UBool)(ucase_toFullTitle(&ucase_props_singleton, c, NULL, NULL, &resultString, "", &locCache)>=0);
+        return (UBool)(ucase_toFullTitle(&ucase_props_singleton, c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0);
     /* case UCHAR_CHANGES_WHEN_CASEFOLDED: -- in uprops.c */
     case UCHAR_CHANGES_WHEN_CASEMAPPED:
-        locCache=UCASE_LOC_ROOT;
         return (UBool)(
-            ucase_toFullLower(&ucase_props_singleton, c, NULL, NULL, &resultString, "", &locCache)>=0 ||
-            ucase_toFullUpper(&ucase_props_singleton, c, NULL, NULL, &resultString, "", &locCache)>=0 ||
-            ucase_toFullTitle(&ucase_props_singleton, c, NULL, NULL, &resultString, "", &locCache)>=0);
+            ucase_toFullLower(&ucase_props_singleton, c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0 ||
+            ucase_toFullUpper(&ucase_props_singleton, c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0 ||
+            ucase_toFullTitle(&ucase_props_singleton, c, NULL, NULL, &resultString, UCASE_LOC_ROOT)>=0);
     default:
         return FALSE;
     }
index 29ea71a533d8c508808cce24f17086fb86d3bb5a..b64e81c7c4df7b0122ef12a238ac39bcd2df6f82 100644 (file)
@@ -56,7 +56,7 @@ ucase_addPropertyStarts(const UCaseProps *csp, const USetAdder *sa, UErrorCode *
  * Accepts both 2- and 3-letter codes and accepts case variants.
  */
 U_CFUNC int32_t
-ucase_getCaseLocale(const char *locale, int32_t *locCache);
+ucase_getCaseLocale(const char *locale);
 
 /* Casing locale types for ucase_getCaseLocale */
 enum {
@@ -240,10 +240,7 @@ enum {
  * @param context Pointer to be passed into iter.
  * @param pString If the mapping result is a string, then the pointer is
  *                written to *pString.
- * @param locale Locale ID for locale-dependent mappings.
- * @param locCache Initialize to 0; may be used to cache the result of parsing
- *                 the locale ID for subsequent calls.
- *                 Can be NULL.
+ * @param caseLocale Case locale value from ucase_getCaseLocale().
  * @return Output code point or string length, see UCASE_MAX_STRING_LENGTH.
  *
  * @see UCaseContextIterator
@@ -254,19 +251,19 @@ U_CAPI int32_t U_EXPORT2
 ucase_toFullLower(const UCaseProps *csp, UChar32 c,
                   UCaseContextIterator *iter, void *context,
                   const UChar **pString,
-                  const char *locale, int32_t *locCache);
+                  int32_t caseLocale);
 
 U_CAPI int32_t U_EXPORT2
 ucase_toFullUpper(const UCaseProps *csp, UChar32 c,
                   UCaseContextIterator *iter, void *context,
                   const UChar **pString,
-                  const char *locale, int32_t *locCache);
+                  int32_t caseLocale);
 
 U_CAPI int32_t U_EXPORT2
 ucase_toFullTitle(const UCaseProps *csp, UChar32 c,
                   UCaseContextIterator *iter, void *context,
                   const UChar **pString,
-                  const char *locale, int32_t *locCache);
+                  int32_t caseLocale);
 
 U_CAPI int32_t U_EXPORT2
 ucase_toFullFolding(const UCaseProps *csp, UChar32 c,
@@ -286,7 +283,7 @@ typedef int32_t U_CALLCONV
 UCaseMapFull(const UCaseProps *csp, UChar32 c,
              UCaseContextIterator *iter, void *context,
              const UChar **pString,
-             const char *locale, int32_t *locCache);
+             int32_t caseLocale);
 
 U_CDECL_END
 
index ef8e80e0557aaeedba48987295b6f27ff8b82ef6..6a4a511ae35310e8d799b484c63e9f7c9fa9e238 100644 (file)
@@ -43,7 +43,7 @@ UCaseMap::UCaseMap(const char *localeID, uint32_t opts, UErrorCode *pErrorCode)
 #if !UCONFIG_NO_BREAK_ITERATION
         iter(NULL),
 #endif
-        locCache(UCASE_LOC_UNKNOWN), options(opts) {
+        caseLocale(UCASE_LOC_UNKNOWN), options(opts) {
     ucasemap_setLocale(this, localeID, pErrorCode);
 }
 
@@ -91,7 +91,7 @@ ucasemap_setLocale(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode) {
     }
     if (locale != NULL && *locale == 0) {
         csm->locale[0] = 0;
-        csm->locCache = UCASE_LOC_ROOT;
+        csm->caseLocale = UCASE_LOC_ROOT;
         return;
     }
 
@@ -105,11 +105,11 @@ ucasemap_setLocale(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode) {
         *pErrorCode=U_BUFFER_OVERFLOW_ERROR;
     }
     if(U_SUCCESS(*pErrorCode)) {
-        csm->locCache=UCASE_LOC_UNKNOWN;
-        ucase_getCaseLocale(csm->locale, &csm->locCache);
+        csm->caseLocale=UCASE_LOC_UNKNOWN;
+        csm->caseLocale = ucase_getCaseLocale(csm->locale);
     } else {
         csm->locale[0]=0;
-        csm->locCache = UCASE_LOC_ROOT;
+        csm->caseLocale = UCASE_LOC_ROOT;
     }
 }
 
@@ -289,7 +289,7 @@ _caseMap(int32_t caseLocale, uint32_t /* TODO: options */, UCaseMapFull *map,
             }
             continue;
         }
-        c=map(NULL, c, utf8_caseContextIterator, csc, &s, NULL, &caseLocale);
+        c=map(NULL, c, utf8_caseContextIterator, csc, &s, caseLocale);
         if((destIndex<destCapacity) && (c<0 ? (c2=~c)<=0x7f : UCASE_MAX_STRING_LENGTH<c && (c2=c)<=0x7f)) {
             /* fast path version of appendResult() for ASCII results */
             dest[destIndex++]=(uint8_t)c2;
@@ -391,7 +391,7 @@ ucasemap_internalUTF8ToTitle(
                 if(c>=0) {
                     csc.cpStart=titleStart;
                     csc.cpLimit=titleLimit;
-                    c=ucase_toFullTitle(NULL, c, utf8_caseContextIterator, &csc, &s, NULL, &caseLocale);
+                    c=ucase_toFullTitle(NULL, c, utf8_caseContextIterator, &csc, &s, caseLocale);
                     destIndex=appendResult(dest, destIndex, destCapacity, c, s);
                 } else {
                     // Malformed UTF-8.
@@ -567,7 +567,7 @@ int32_t toUpper(int32_t caseLocale, uint32_t /* TODO: options */,
         } else if(c>=0) {
             const UChar *s;
             UChar32 c2 = 0;
-            c=ucase_toFullUpper(NULL, c, NULL, NULL, &s, NULL, &caseLocale);
+            c=ucase_toFullUpper(NULL, c, NULL, NULL, &s, caseLocale);
             if((destIndex<destCapacity) && (c<0 ? (c2=~c)<=0x7f : UCASE_MAX_STRING_LENGTH<c && (c2=c)<=0x7f)) {
                 /* fast path version of appendResult() for ASCII results */
                 dest[destIndex++]=(uint8_t)c2;
@@ -724,7 +724,7 @@ ucasemap_utf8ToLower(const UCaseMap *csm,
                      const char *src, int32_t srcLength,
                      UErrorCode *pErrorCode) {
     return ucasemap_mapUTF8(
-        csm->locCache, csm->options, UCASEMAP_BREAK_ITERATOR_NULL
+        csm->caseLocale, csm->options, UCASEMAP_BREAK_ITERATOR_NULL
         (uint8_t *)dest, destCapacity,
         (const uint8_t *)src, srcLength,
         ucasemap_internalUTF8ToLower, pErrorCode);
@@ -736,7 +736,7 @@ ucasemap_utf8ToUpper(const UCaseMap *csm,
                      const char *src, int32_t srcLength,
                      UErrorCode *pErrorCode) {
     return ucasemap_mapUTF8(
-        csm->locCache, csm->options, UCASEMAP_BREAK_ITERATOR_NULL
+        csm->caseLocale, csm->options, UCASEMAP_BREAK_ITERATOR_NULL
         (uint8_t *)dest, destCapacity,
         (const uint8_t *)src, srcLength,
         ucasemap_internalUTF8ToUpper, pErrorCode);
index 908c1e3d333bd999473e7fee1c9281f61e29e81b..ca0d5463ca96fba64bd69494ef2d5ca5dd5b30d5 100644 (file)
@@ -62,7 +62,7 @@ ucasemap_utf8ToTitle(UCaseMap *csm,
     }
     csm->iter->setText(&utext, *pErrorCode);
     int32_t length=ucasemap_mapUTF8(
-            csm->locCache, csm->options, csm->iter,
+            csm->caseLocale, csm->options, csm->iter,
             (uint8_t *)dest, destCapacity,
             (const uint8_t *)src, srcLength,
             ucasemap_internalUTF8ToTitle, pErrorCode);
index b6bc64f03c0a5e60cc204e126df06cad0f2eef1b..561eeb73a972c69241c72008e6d5b1ce59bdf701 100644 (file)
@@ -207,7 +207,6 @@ UnicodeSet& UnicodeSet::closeOver(int32_t attribute) {
             int32_t n = getRangeCount();
             UChar32 result;
             const UChar *full;
-            int32_t locCache = 0;
 
             for (int32_t i=0; i<n; ++i) {
                 UChar32 start = getRangeStart(i);
@@ -222,13 +221,13 @@ UnicodeSet& UnicodeSet::closeOver(int32_t attribute) {
                     // add case mappings
                     // (does not add long s for regular s, or Kelvin for k, for example)
                     for (UChar32 cp=start; cp<=end; ++cp) {
-                        result = ucase_toFullLower(csp, cp, NULL, NULL, &full, "", &locCache);
+                        result = ucase_toFullLower(csp, cp, NULL, NULL, &full, UCASE_LOC_ROOT);
                         addCaseMapping(foldSet, result, full, str);
 
-                        result = ucase_toFullTitle(csp, cp, NULL, NULL, &full, "", &locCache);
+                        result = ucase_toFullTitle(csp, cp, NULL, NULL, &full, UCASE_LOC_ROOT);
                         addCaseMapping(foldSet, result, full, str);
 
-                        result = ucase_toFullUpper(csp, cp, NULL, NULL, &full, "", &locCache);
+                        result = ucase_toFullUpper(csp, cp, NULL, NULL, &full, UCASE_LOC_ROOT);
                         addCaseMapping(foldSet, result, full, str);
 
                         result = ucase_toFullFolding(csp, cp, &full, 0);
index b1382ff7c7b419d1782d746e72693eb5389e2ff8..e4a6ab70660644041a6cef388225dd4ef01f5ad7 100644 (file)
@@ -116,32 +116,22 @@ uprv_loadPropsData(UErrorCode *errorCode);*/
 struct UCaseMap : public icu::UMemory {
     /** Implements most of ucasemap_open(). */
     UCaseMap(const char *localeID, uint32_t opts, UErrorCode *pErrorCode);
-    /** Root locale. */
-    UCaseMap(uint32_t opts) :
-#if !UCONFIG_NO_BREAK_ITERATION
-            iter(NULL),
-#endif
-            locCache(/* UCASE_LOC_ROOT= */ 1), options(opts) {
-        locale[0] = 0;
-    }
     ~UCaseMap();
 
 #if !UCONFIG_NO_BREAK_ITERATION
     icu::BreakIterator *iter;  /* We adopt the iterator, so we own it. */
 #endif
     char locale[32];
-    int32_t locCache;
+    int32_t caseLocale;
     uint32_t options;
 };
 
 #if UCONFIG_NO_BREAK_ITERATION
-#   define UCASEMAP_INITIALIZER { NULL, { 0 }, 0, 0 }
 #   define UCASEMAP_BREAK_ITERATOR_PARAM
 #   define UCASEMAP_BREAK_ITERATOR_UNUSED
 #   define UCASEMAP_BREAK_ITERATOR
 #   define UCASEMAP_BREAK_ITERATOR_NULL
 #else
-#   define UCASEMAP_INITIALIZER { NULL, NULL, { 0 }, 0, 0 }
 #   define UCASEMAP_BREAK_ITERATOR_PARAM icu::BreakIterator *iter,
 #   define UCASEMAP_BREAK_ITERATOR_UNUSED icu::BreakIterator *,
 #   define UCASEMAP_BREAK_ITERATOR iter,
index 695ea0be06a9e3772b65b33dca3808ccd89093c8..1072e43ce41c1ccfc494cada5773a3e1c96006f0 100644 (file)
@@ -31,8 +31,6 @@
 
 U_NAMESPACE_USE
 
-// TODO: create casemap.cpp
-
 /* functions available in the common library (for unistr_case.cpp) */
 
 /* public API functions */
@@ -106,7 +104,7 @@ ucasemap_toTitle(UCaseMap *csm,
     UnicodeString s(srcLength<0, src, srcLength);
     csm->iter->setText(s);
     return ustrcase_map(
-        csm->locCache, csm->options, csm->iter,
+        csm->caseLocale, csm->options, csm->iter,
         dest, destCapacity,
         src, srcLength,
         ustrcase_internalToTitle, NULL, *pErrorCode);
index 15a1fc711e3981eaafcbfde06027c6166cbfc518..127790163a86c29d9062e0df9640a2df717d22e7 100644 (file)
@@ -554,7 +554,7 @@ _caseMap(int32_t caseLocale, uint32_t options, UCaseMapFull *map,
         U16_NEXT(src, srcIndex, srcLimit, c);
         csc->cpLimit=srcIndex;
         const UChar *s;
-        c=map(NULL, c, utf16_caseContextIterator, csc, &s, NULL, &caseLocale);
+        c=map(NULL, c, utf16_caseContextIterator, csc, &s, caseLocale);
         destIndex = appendResult(dest, destIndex, destCapacity, c, s,
                                  srcIndex - cpStart, options, edits);
         if (destIndex < 0) {
@@ -648,8 +648,7 @@ ustrcase_internalToTitle(int32_t caseLocale, uint32_t options, BreakIterator *it
                 csc.cpStart=titleStart;
                 csc.cpLimit=titleLimit;
                 const UChar *s;
-                c=ucase_toFullTitle(NULL, c, utf16_caseContextIterator, &csc, &s,
-                                    NULL, &caseLocale);
+                c=ucase_toFullTitle(NULL, c, utf16_caseContextIterator, &csc, &s, caseLocale);
                 destIndex=appendResult(dest, destIndex, destCapacity, c, s,
                                        titleLimit-titleStart, options, edits);
                 if(destIndex<0) {
@@ -1318,7 +1317,7 @@ int32_t toUpper(int32_t caseLocale, uint32_t options,
             }
         } else {
             const UChar *s;
-            c=ucase_toFullUpper(NULL, c, NULL, NULL, &s, NULL, &caseLocale);
+            c=ucase_toFullUpper(NULL, c, NULL, NULL, &s, caseLocale);
             destIndex = appendResult(dest, destIndex, destCapacity, c, s,
                                      nextIndex - i, options, edits);
             if (destIndex < 0) {
index 7cf9301736eb119694c23550dc6ac3deac007d6d..74b3ab17ddac57b39eee72573f3ce52fa8a65084 100644 (file)
@@ -34,7 +34,7 @@ ustrcase_getCaseLocale(const char *locale) {
     if (*locale == 0) {
         return UCASE_LOC_ROOT;
     } else {
-        return ucase_getCaseLocale(locale, NULL);
+        return ucase_getCaseLocale(locale);
     }
 }
 
index 9c8c8b947c9113c428e26818958f8c12932132a4..9a0bc0c7569875dacb0933e1e572d25bb7f4f7cc 100644 (file)
@@ -151,14 +151,14 @@ void CaseMapTransliterator::handleTransliterate(Replaceable& text,
     UnicodeString tmp;
     const UChar *s;
     UChar32 c;
-    int32_t textPos, delta, result, locCache=0;
+    int32_t textPos, delta, result;
 
     for(textPos=offsets.start; textPos<offsets.limit;) {
         csc.cpStart=textPos;
         c=text.char32At(textPos);
         csc.cpLimit=textPos+=U16_LENGTH(c);
 
-        result=fMap(fCsp, c, utrans_rep_caseContextIterator, &csc, &s, "", &locCache);
+        result=fMap(fCsp, c, utrans_rep_caseContextIterator, &csc, &s, UCASE_LOC_ROOT);
 
         if(csc.b1 && isIncremental) {
             // fMap() tried to look beyond the context limit
index b5896167871d5758c242fc42407bec3f796cccb1..125630389c0aa53959374a2f1c3a9bfeb23ff402 100644 (file)
@@ -118,7 +118,7 @@ void TitlecaseTransliterator::handleTransliterate(
 
     UnicodeString tmp;
     const UChar *s;
-    int32_t textPos, delta, result, locCache=0;
+    int32_t textPos, delta, result;
 
     for(textPos=offsets.start; textPos<offsets.limit;) {
         csc.cpStart=textPos;
@@ -128,9 +128,9 @@ void TitlecaseTransliterator::handleTransliterate(
         type=ucase_getTypeOrIgnorable(fCsp, c);
         if(type>=0) { // not case-ignorable
             if(doTitle) {
-                result=ucase_toFullTitle(fCsp, c, utrans_rep_caseContextIterator, &csc, &s, "", &locCache);
+                result=ucase_toFullTitle(fCsp, c, utrans_rep_caseContextIterator, &csc, &s, UCASE_LOC_ROOT);
             } else {
-                result=ucase_toFullLower(fCsp, c, utrans_rep_caseContextIterator, &csc, &s, "", &locCache);
+                result=ucase_toFullLower(fCsp, c, utrans_rep_caseContextIterator, &csc, &s, UCASE_LOC_ROOT);
             }
             doTitle = (UBool)(type==0); // doTitle=isUncased