Avoid copying PrettyStackTrace messages an extra time on Apple OSs
authorJordan Rose <jordan_rose@apple.com>
Fri, 15 Jun 2018 16:35:31 +0000 (16:35 +0000)
committerJordan Rose <jordan_rose@apple.com>
Fri, 15 Jun 2018 16:35:31 +0000 (16:35 +0000)
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!

llvm-svn: 334841

llvm/lib/Support/PrettyStackTrace.cpp

index 9d62d74..f5b6e6f 100644 (file)
@@ -118,9 +118,9 @@ static void CrashHandler(void *) {
   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();
   }