[libc-commits] [PATCH] D106511: [libc] Add explicit C++ casting to strrchr

Alf via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jul 21 17:02:44 PDT 2021


gAlfonso-bit created this revision.
gAlfonso-bit added a reviewer: LLVM.
gAlfonso-bit added a project: LLVM.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added a project: libc-project.
gAlfonso-bit requested review of this revision.

We need to explicitly choose the fastest and most efficient C++ cast to ensure we can get the best performance out of this already slow function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106511

Files:
  libc/src/string/strrchr.cpp


Index: libc/src/string/strrchr.cpp
===================================================================
--- libc/src/string/strrchr.cpp
+++ libc/src/string/strrchr.cpp
@@ -13,7 +13,7 @@
 namespace __llvm_libc {
 
 LLVM_LIBC_FUNCTION(char *, strrchr, (const char *src, int c)) {
-  const char ch = c;
+  const char ch = static_cast<char>(c);
   char *last_occurrence = nullptr;
   do {
     if (*src == ch)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106511.360650.patch
Type: text/x-patch
Size: 405 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210722/2c4df525/attachment.bin>


More information about the libc-commits mailing list