[Lldb-commits] [lldb] 317461e - [lldb-dap] Avoid a std::string allocation for the help output (NFC)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 26 09:57:09 PST 2025


Author: Jonas Devlieghere
Date: 2025-02-26T11:56:23-06:00
New Revision: 317461ed61002de7f6e54ab0a26780c6d2726bb0

URL: https://github.com/llvm/llvm-project/commit/317461ed61002de7f6e54ab0a26780c6d2726bb0
DIFF: https://github.com/llvm/llvm-project/commit/317461ed61002de7f6e54ab0a26780c6d2726bb0.diff

LOG: [lldb-dap] Avoid a std::string allocation for the help output (NFC)

Don't create a temporary `std::string` for the help output, just write
it to `llvm::outs()` directly.

Added: 
    

Modified: 
    lldb/tools/lldb-dap/lldb-dap.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index 3b029b2ef047a..1c6bd7e903409 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -161,7 +161,7 @@ static void printHelp(LLDBDAPOptTable &table, llvm::StringRef tool_name) {
   std::string usage_str = tool_name.str() + " options";
   table.printHelp(llvm::outs(), usage_str.c_str(), "LLDB DAP", false);
 
-  std::string examples = R"___(
+  llvm::outs() << R"___(
 EXAMPLES:
   The debug adapter can be started in two modes.
 
@@ -176,7 +176,6 @@ static void printHelp(LLDBDAPOptTable &table, llvm::StringRef tool_name) {
 
     lldb-dap -g
 )___";
-  llvm::outs() << examples;
 }
 
 // If --launch-target is provided, this instance of lldb-dap becomes a


        


More information about the lldb-commits mailing list