Convert GetNameColonValue to return StringRefs.
StringExtractor::GetNameColonValue() looks for a substring of the
form "<name>:<value>" and returns <name> and <value> to the caller.
This results in two unnecessary string copies, since the name and
value are not translated in any way and simply returned as-is.
By converting this to return StringRefs we can get rid of hundreds
of string copies.
llvm-svn: 280000
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
index 4f11a03..c9baed7 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -184,15 +184,15 @@
ConnectionFileDescriptor file_conn;
std::string hostname;
packet.SetFilePos(::strlen ("qLaunchGDBServer;"));
- std::string name;
- std::string value;
+ llvm::StringRef name;
+ llvm::StringRef value;
uint16_t port = UINT16_MAX;
while (packet.GetNameColonValue(name, value))
{
- if (name.compare ("host") == 0)
- hostname.swap(value);
- else if (name.compare ("port") == 0)
- port = StringConvert::ToUInt32(value.c_str(), 0, 0);
+ if (name.equals("host"))
+ hostname = value;
+ else if (name.equals("port"))
+ value.getAsInteger(0, port);
}
lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID;