Merge "ASCII fastpath for towupper and towlower." am: 57a64a7172 am: 3355fdc3fc
am: cbcbc0c753

Change-Id: Ibbca1f537bcb4ad67e3f9dffcf619798fba73e1d
diff --git a/libc/bionic/wctype.cpp b/libc/bionic/wctype.cpp
index 6e33b6c..061f55a 100644
--- a/libc/bionic/wctype.cpp
+++ b/libc/bionic/wctype.cpp
@@ -117,12 +117,22 @@
 }
 
 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);