From aa27217a84bb45082dd6f90103227fedca34c446 Mon Sep 17 00:00:00 2001 From: Markus Scherer <markus.icu@gmail.com> Date: Fri, 20 Jan 2017 06:27:47 +0000 Subject: [PATCH] ICU-12410 remove locCache behavior from ucase_getCaseLocale() and functions that call it, try to make it a little faster for common locale IDs X-SVN-Rev: 39586 --- icu4c/source/common/ucase.cpp | 211 +++++++++++------- icu4c/source/common/ucase.h | 15 +- icu4c/source/common/ucasemap.cpp | 20 +- .../common/ucasemap_titlecase_brkiter.cpp | 2 +- icu4c/source/common/uniset_closure.cpp | 7 +- icu4c/source/common/ustr_imp.h | 12 +- .../source/common/ustr_titlecase_brkiter.cpp | 4 +- icu4c/source/common/ustrcase.cpp | 7 +- icu4c/source/common/ustrcase_locale.cpp | 2 +- icu4c/source/i18n/casetrn.cpp | 4 +- icu4c/source/i18n/titletrn.cpp | 6 +- 11 files changed, 165 insertions(+), 125 deletions(-) diff --git a/icu4c/source/common/ucase.cpp b/icu4c/source/common/ucase.cpp index 051c914da31..8e2455fbe1e 100644 --- a/icu4c/source/common/ucase.cpp +++ b/icu4c/source/common/ucase.cpp @@ -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; } diff --git a/icu4c/source/common/ucase.h b/icu4c/source/common/ucase.h index 29ea71a533d..b64e81c7c4d 100644 --- a/icu4c/source/common/ucase.h +++ b/icu4c/source/common/ucase.h @@ -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 diff --git a/icu4c/source/common/ucasemap.cpp b/icu4c/source/common/ucasemap.cpp index ef8e80e0557..6a4a511ae35 100644 --- a/icu4c/source/common/ucasemap.cpp +++ b/icu4c/source/common/ucasemap.cpp @@ -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); diff --git a/icu4c/source/common/ucasemap_titlecase_brkiter.cpp b/icu4c/source/common/ucasemap_titlecase_brkiter.cpp index 908c1e3d333..ca0d5463ca9 100644 --- a/icu4c/source/common/ucasemap_titlecase_brkiter.cpp +++ b/icu4c/source/common/ucasemap_titlecase_brkiter.cpp @@ -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); diff --git a/icu4c/source/common/uniset_closure.cpp b/icu4c/source/common/uniset_closure.cpp index b6bc64f03c0..561eeb73a97 100644 --- a/icu4c/source/common/uniset_closure.cpp +++ b/icu4c/source/common/uniset_closure.cpp @@ -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); diff --git a/icu4c/source/common/ustr_imp.h b/icu4c/source/common/ustr_imp.h index b1382ff7c7b..e4a6ab70660 100644 --- a/icu4c/source/common/ustr_imp.h +++ b/icu4c/source/common/ustr_imp.h @@ -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, diff --git a/icu4c/source/common/ustr_titlecase_brkiter.cpp b/icu4c/source/common/ustr_titlecase_brkiter.cpp index 695ea0be06a..1072e43ce41 100644 --- a/icu4c/source/common/ustr_titlecase_brkiter.cpp +++ b/icu4c/source/common/ustr_titlecase_brkiter.cpp @@ -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); diff --git a/icu4c/source/common/ustrcase.cpp b/icu4c/source/common/ustrcase.cpp index 15a1fc711e3..127790163a8 100644 --- a/icu4c/source/common/ustrcase.cpp +++ b/icu4c/source/common/ustrcase.cpp @@ -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) { diff --git a/icu4c/source/common/ustrcase_locale.cpp b/icu4c/source/common/ustrcase_locale.cpp index 7cf9301736e..74b3ab17dda 100644 --- a/icu4c/source/common/ustrcase_locale.cpp +++ b/icu4c/source/common/ustrcase_locale.cpp @@ -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); } } diff --git a/icu4c/source/i18n/casetrn.cpp b/icu4c/source/i18n/casetrn.cpp index 9c8c8b947c9..9a0bc0c7569 100644 --- a/icu4c/source/i18n/casetrn.cpp +++ b/icu4c/source/i18n/casetrn.cpp @@ -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 diff --git a/icu4c/source/i18n/titletrn.cpp b/icu4c/source/i18n/titletrn.cpp index b5896167871..125630389c0 100644 --- a/icu4c/source/i18n/titletrn.cpp +++ b/icu4c/source/i18n/titletrn.cpp @@ -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 -- 2.40.0