mirror of
https://github.com/intel/llvm.git
synced 2026-01-20 01:58:44 +08:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user