Author: Ebuka Ezike
Date: 2025-12-23T13:02:37Z
New Revision: 2c8a4b8497d9da6812d7e985b77554f99b87c683

URL: 
https://github.com/llvm/llvm-project/commit/2c8a4b8497d9da6812d7e985b77554f99b87c683
DIFF: 
https://github.com/llvm/llvm-project/commit/2c8a4b8497d9da6812d7e985b77554f99b87c683.diff

LOG: [lldb][NFC] Remove temp allocation SBCommandReturnObject::PutCString 
(#173365)

Use llvm::StringRef instead of std::string to eliminate an unnecessary
heap allocation when len > 0.

There should not be any functional difference.

Added: 
    

Modified: 
    lldb/source/API/SBCommandReturnObject.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/API/SBCommandReturnObject.cpp 
b/lldb/source/API/SBCommandReturnObject.cpp
index da7e288e38d28..61bd06eadbbf9 100644
--- a/lldb/source/API/SBCommandReturnObject.cpp
+++ b/lldb/source/API/SBCommandReturnObject.cpp
@@ -315,8 +315,8 @@ void SBCommandReturnObject::PutCString(const char *string, 
int len) {
   if (len == 0 || string == nullptr || *string == 0) {
     return;
   } else if (len > 0) {
-    std::string buffer(string, len);
-    ref().AppendMessage(buffer.c_str());
+    const llvm::StringRef buffer{string, static_cast<size_t>(len)};
+    ref().AppendMessage(buffer);
   } else
     ref().AppendMessage(string);
 }


        
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to