Merge "ASCII fastpath for towupper and towlower."

am: 57a64a7172

Change-Id: Iaee20d1c71f6f87d2f44d185ed85a15783326067
This commit is contained in:
Elliott Hughes 2019-09-27 10:42:43 -07:00 committed by android-build-merger
commit 3355fdc3fc

View file

@ -117,12 +117,22 @@ int iswctype_l(wint_t wc, wctype_t char_class, locale_t) {
}
wint_t towlower(wint_t wc) {
if (wc < 0x80) {
if (wc >= 'A' && wc <= 'Z') return wc | 0x20;
return wc;
}
typedef UChar32 (*FnT)(UChar32);
static auto u_tolower = reinterpret_cast<FnT>(__find_icu_symbol("u_tolower"));
return u_tolower ? u_tolower(wc) : tolower(wc);
}
wint_t towupper(wint_t wc) {
if (wc < 0x80) {
if (wc >= 'a' && wc <= 'z') return wc & 0xdf;
return wc;
}
typedef UChar32 (*FnT)(UChar32);
static auto u_toupper = reinterpret_cast<FnT>(__find_icu_symbol("u_toupper"));
return u_toupper ? u_toupper(wc) : toupper(wc);