mirror of
https://github.com/intel/llvm.git
synced 2026-02-04 20:00:11 +08:00
Modernize UUID class
Instead of a separate GetBytes + GetByteSize methods I introduce a single GetBytes method returning an ArrayRef. This is NFC cleanup now, but it should make handling arbitrarily-sized UUIDs cleaner, should we choose to go that way. I also took the opportunity to add some unit tests for this class. llvm-svn: 335244
This commit is contained in:
@@ -86,17 +86,12 @@ size_t OptionValueUUID::AutoComplete(CommandInterpreter &interpreter,
|
||||
if (module_sp) {
|
||||
const UUID &module_uuid = module_sp->GetUUID();
|
||||
if (module_uuid.IsValid()) {
|
||||
bool add_uuid = false;
|
||||
if (num_bytes_decoded == 0)
|
||||
add_uuid = true;
|
||||
else
|
||||
add_uuid = ::memcmp(module_uuid.GetBytes(), uuid_bytes,
|
||||
num_bytes_decoded) == 0;
|
||||
if (add_uuid) {
|
||||
std::string uuid_str;
|
||||
uuid_str = module_uuid.GetAsString();
|
||||
if (!uuid_str.empty())
|
||||
matches.AppendString(uuid_str.c_str());
|
||||
llvm::ArrayRef<uint8_t> decoded_bytes(uuid_bytes,
|
||||
num_bytes_decoded);
|
||||
llvm::ArrayRef<uint8_t> module_bytes = module_uuid.GetBytes();
|
||||
if (module_bytes.size() >= num_bytes_decoded &&
|
||||
module_bytes.take_front(num_bytes_decoded) == decoded_bytes) {
|
||||
matches.AppendString(module_uuid.GetAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user