[Lldb-commits] [PATCH] D40537: Simplify UUID::IsValid()
Stephane Sezer via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Nov 27 18:14:57 PST 2017
sas created this revision.
This change also prevents looking further than the size of the current
UUID.
https://reviews.llvm.org/D40537
Files:
source/Utility/UUID.cpp
Index: source/Utility/UUID.cpp
===================================================================
--- source/Utility/UUID.cpp
+++ source/Utility/UUID.cpp
@@ -15,9 +15,12 @@
#include "llvm/ADT/StringRef.h"
// C Includes
+// C++ Includes
#include <ctype.h>
#include <stdio.h>
#include <string.h>
+#include <algorithm>
+#include <iterator>
namespace lldb_private {
@@ -104,10 +107,8 @@
size_t UUID::GetByteSize() const { return m_num_uuid_bytes; }
bool UUID::IsValid() const {
- return m_uuid[0] || m_uuid[1] || m_uuid[2] || m_uuid[3] || m_uuid[4] ||
- m_uuid[5] || m_uuid[6] || m_uuid[7] || m_uuid[8] || m_uuid[9] ||
- m_uuid[10] || m_uuid[11] || m_uuid[12] || m_uuid[13] || m_uuid[14] ||
- m_uuid[15] || m_uuid[16] || m_uuid[17] || m_uuid[18] || m_uuid[19];
+ return std::any_of(std::begin(m_uuid), std::begin(m_uuid) + m_num_uuid_bytes,
+ [](uint32_t val) { return val != 0; });
}
static inline int xdigit_to_int(char ch) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40537.124507.patch
Type: text/x-patch
Size: 991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20171128/f72f0863/attachment.bin>
More information about the lldb-commits
mailing list