towlower()/towupper(): reuse tolower()/toupper().
Now <ctype.h> tolower() and toupper() are inlined, we don't need to
duplicate the code in the towlower() and towupper() fast paths to avoid
a function call.
Test: treehugger
Change-Id: Ie9ae78500a3ea253756b8bbb9cc9ea86774ff616
diff --git a/libc/bionic/wctype.cpp b/libc/bionic/wctype.cpp
index 76f922f..b37f17b 100644
--- a/libc/bionic/wctype.cpp
+++ b/libc/bionic/wctype.cpp
@@ -109,10 +109,7 @@
}
wint_t towlower(wint_t wc) {
- if (wc < 0x80) {
- if (wc >= 'A' && wc <= 'Z') return wc | 0x20;
- return wc;
- }
+ if (wc < 0x80) return tolower(wc);
typedef UChar32 (*FnT)(UChar32);
static auto u_tolower = reinterpret_cast<FnT>(__find_icu_symbol("u_tolower"));
@@ -120,12 +117,7 @@
}
wint_t towupper(wint_t wc) {
- if (wc < 0x80) {
- // Using EOR rather than AND makes no difference on arm, but saves an
- // instruction on arm64.
- if (wc >= 'a' && wc <= 'z') return wc ^ 0x20;
- return wc;
- }
+ if (wc < 0x80) return toupper(wc);
typedef UChar32 (*FnT)(UChar32);
static auto u_toupper = reinterpret_cast<FnT>(__find_icu_symbol("u_toupper"));