Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit d05459d

Browse files
Treehugger RobotGerrit Code Review
authored andcommitted
Merge "towlower()/towupper(): reuse tolower()/toupper()." into main
2 parents 58557e1 + 5261283 commit d05459d

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

libc/bionic/wctype.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,15 @@ int iswctype_l(wint_t wc, wctype_t char_class, locale_t) {
109109
}
110110

111111
wint_t towlower(wint_t wc) {
112-
if (wc < 0x80) {
113-
if (wc >= 'A' && wc <= 'Z') return wc | 0x20;
114-
return wc;
115-
}
112+
if (wc < 0x80) return tolower(wc);
116113

117114
typedef UChar32 (*FnT)(UChar32);
118115
static auto u_tolower = reinterpret_cast<FnT>(__find_icu_symbol("u_tolower"));
119116
return u_tolower ? u_tolower(wc) : tolower(wc);
120117
}
121118

122119
wint_t towupper(wint_t wc) {
123-
if (wc < 0x80) {
124-
// Using EOR rather than AND makes no difference on arm, but saves an
125-
// instruction on arm64.
126-
if (wc >= 'a' && wc <= 'z') return wc ^ 0x20;
127-
return wc;
128-
}
120+
if (wc < 0x80) return toupper(wc);
129121

130122
typedef UChar32 (*FnT)(UChar32);
131123
static auto u_toupper = reinterpret_cast<FnT>(__find_icu_symbol("u_toupper"));

0 commit comments

Comments
 (0)