[libcxx-commits] [libcxx] [libc++] Optimize ctype::to{lower, upper} (PR #145344)
Zibi Sarbinowski via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Aug 15 09:22:05 PDT 2025
================
@@ -697,6 +697,20 @@ const ctype_base::mask ctype_base::graph;
// template <> class ctype<wchar_t>;
+template <class CharT>
+static CharT to_upper_impl(CharT c) {
+ if (c < 'a' || c > 'z')
+ return c;
+ return c & ~0x20;
+}
+
+template <class CharT>
+static CharT to_lower_impl(CharT c) {
+ if (c < 'A' || c > 'Z')
+ return c;
+ return c | 0x20;
+}
+
----------------
zibi2 wrote:
Assuming system call to :tolower(c) and touppoer(c) are macro expanded and/or get inlined the performance should be equivalent to above implementation, isn't it?
https://github.com/llvm/llvm-project/pull/145344
More information about the libcxx-commits
mailing list