Update StructuredData::String to return StringRefs.

It was returning const std::string& which was leading to
unnecessary copies all over the place, and preventing people
from doing things like Dict->GetValueForKeyAsString("foo", ref);

llvm-svn: 302875
This commit is contained in:
Zachary Turner
2017-05-12 05:49:54 +00:00
parent 41c9936460
commit 2833321f09
32 changed files with 122 additions and 134 deletions

View File

@@ -160,12 +160,9 @@ llvm::StringRef UUID::DecodeUUIDBytesFromString(llvm::StringRef p,
bytes_decoded = uuid_byte_idx;
return p;
}
size_t UUID::SetFromCString(const char *cstr, uint32_t num_uuid_bytes) {
if (cstr == NULL)
return 0;
llvm::StringRef orig(cstr);
llvm::StringRef p = orig;
size_t UUID::SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes) {
llvm::StringRef p = str;
// Skip leading whitespace characters
p = p.ltrim();
@@ -178,12 +175,19 @@ size_t UUID::SetFromCString(const char *cstr, uint32_t num_uuid_bytes) {
// were consumed
if (bytes_decoded == num_uuid_bytes) {
m_num_uuid_bytes = num_uuid_bytes;
return orig.size() - rest.size();
return str.size() - rest.size();
}
// Else return zero to indicate we were not able to parse a UUID value
return 0;
}
size_t UUID::SetFromCString(const char *cstr, uint32_t num_uuid_bytes) {
if (cstr == NULL)
return 0;
return SetFromStringRef(cstr, num_uuid_bytes);
}
}
bool lldb_private::operator==(const lldb_private::UUID &lhs,