From d7796855b87911b8ae6c726ab5df4949f173dbd2 Mon Sep 17 00:00:00 2001 From: Youngsuk Kim Date: Mon, 16 Sep 2024 00:26:51 -0400 Subject: [lldb] Nits on uses of llvm::raw_string_ostream (NFC) (#108745) As specified in the docs, 1) raw_string_ostream is always unbuffered and 2) the underlying buffer may be used directly ( 65b13610a5226b84889b923bae884ba395ad084d for further reference ) * Don't call raw_string_ostream::flush(), which is essentially a no-op. * Avoid unneeded calls to raw_string_ostream::str(), to avoid excess indirection. --- .../Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp') diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 23baa92..d005cf1 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -3668,7 +3668,6 @@ GDBRemoteCommunicationClient::SendTraceStop(const TraceStopRequest &request, std::string json_string; llvm::raw_string_ostream os(json_string); os << toJSON(request); - os.flush(); escaped_packet.PutEscapedBytes(json_string.c_str(), json_string.size()); @@ -3738,7 +3737,6 @@ GDBRemoteCommunicationClient::SendTraceGetState(llvm::StringRef type, std::string json_string; llvm::raw_string_ostream os(json_string); os << toJSON(TraceGetStateRequest{type.str()}); - os.flush(); escaped_packet.PutEscapedBytes(json_string.c_str(), json_string.size()); @@ -3772,7 +3770,6 @@ GDBRemoteCommunicationClient::SendTraceGetBinaryData( std::string json_string; llvm::raw_string_ostream os(json_string); os << toJSON(request); - os.flush(); escaped_packet.PutEscapedBytes(json_string.c_str(), json_string.size()); @@ -4045,7 +4042,7 @@ GDBRemoteCommunicationClient::ReadExtFeature(llvm::StringRef object, } } - return output_stream.str(); + return output; } // Notify the target that gdb is prepared to serve symbol lookup requests. -- cgit v1.1