[PATCH] D48197: Avoid copying PrettyStackTrace messages an extra time on Apple platforms

Jordan Rose via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 14 14:12:18 PDT 2018


jordan_rose created this revision.
jordan_rose added reviewers: dsanders, beanz.

We were unnecessarily going from SmallString to std::string just to get a null-terminated C string. So just…don't do that. Crash slightly faster!


Repository:
  rL LLVM

https://reviews.llvm.org/D48197

Files:
  lib/Support/PrettyStackTrace.cpp


Index: lib/Support/PrettyStackTrace.cpp
===================================================================
--- lib/Support/PrettyStackTrace.cpp
+++ lib/Support/PrettyStackTrace.cpp
@@ -118,9 +118,9 @@
   if (!TmpStr.empty()) {
 #ifdef HAVE_CRASHREPORTERCLIENT_H
     // Cast to void to avoid warning.
-    (void)CRSetCrashLogMessage(std::string(TmpStr.str()).c_str());
+    (void)CRSetCrashLogMessage(TmpStr.c_str());
 #elif HAVE_CRASHREPORTER_INFO 
-    __crashreporter_info__ = strdup(std::string(TmpStr.str()).c_str());
+    __crashreporter_info__ = strdup(TmpStr.c_str());
 #endif
     errs() << TmpStr.str();
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48197.151424.patch
Type: text/x-patch
Size: 620 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180614/1bd005d4/attachment.bin>


More information about the llvm-commits mailing list