mirror of
https://github.com/intel/llvm.git
synced 2026-01-28 01:04:49 +08:00
[lldb-dap] Avoid creating temporary instances of std::string (NFC) (#140325)
EmplaceSafeString accepts StringRef for the last parameter, str, and then internally creates a copy of str via StringRef::str or llvm::json::fixUTF8, so caller do not need to create their own temporary instances of std::string.
This commit is contained in:
@@ -93,7 +93,7 @@ void SendProcessEvent(DAP &dap, LaunchMethod launch_method) {
|
||||
exe_fspec.GetPath(exe_path, sizeof(exe_path));
|
||||
llvm::json::Object event(CreateEventObject("process"));
|
||||
llvm::json::Object body;
|
||||
EmplaceSafeString(body, "name", std::string(exe_path));
|
||||
EmplaceSafeString(body, "name", exe_path);
|
||||
const auto pid = dap.target.GetProcess().GetProcessID();
|
||||
body.try_emplace("systemProcessId", (int64_t)pid);
|
||||
body.try_emplace("isLocalProcess", true);
|
||||
|
||||
@@ -205,7 +205,7 @@ void EvaluateRequestHandler::operator()(
|
||||
lldb::SBError error = value.GetError();
|
||||
const char *error_cstr = error.GetCString();
|
||||
if (error_cstr && error_cstr[0])
|
||||
EmplaceSafeString(response, "message", std::string(error_cstr));
|
||||
EmplaceSafeString(response, "message", error_cstr);
|
||||
else
|
||||
EmplaceSafeString(response, "message", "evaluate failed");
|
||||
} else {
|
||||
|
||||
@@ -136,7 +136,7 @@ void ExceptionInfoRequestHandler::operator()(
|
||||
if (!ObjectContainsKey(body, "description")) {
|
||||
char description[1024];
|
||||
if (thread.GetStopDescription(description, sizeof(description))) {
|
||||
EmplaceSafeString(body, "description", std::string(description));
|
||||
EmplaceSafeString(body, "description", description);
|
||||
}
|
||||
}
|
||||
body.try_emplace("breakMode", "always");
|
||||
|
||||
@@ -905,7 +905,7 @@ llvm::json::Value CreateThreadStopped(DAP &dap, lldb::SBThread &thread,
|
||||
if (!ObjectContainsKey(body, "description")) {
|
||||
char description[1024];
|
||||
if (thread.GetStopDescription(description, sizeof(description))) {
|
||||
EmplaceSafeString(body, "description", std::string(description));
|
||||
EmplaceSafeString(body, "description", description);
|
||||
}
|
||||
}
|
||||
// "threadCausedFocus" is used in tests to validate breaking behavior.
|
||||
|
||||
Reference in New Issue
Block a user