Skip to content

Commit f6f05c4

Browse files
committed
constexpr + noexcept in guid.h
1 parent 3f0c424 commit f6f05c4

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/common/os/guid.h

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ static_assert(sizeof(UUID) == 16, "Guid size mismatch");
5151

5252
namespace Firebird {
5353

54-
const int GUID_BUFF_SIZE = 39;
55-
const int GUID_BODY_SIZE = 36;
54+
inline constexpr int GUID_BUFF_SIZE = 39;
55+
inline constexpr int GUID_BODY_SIZE = 36;
5656

5757
void GenerateRandomBytes(void* buffer, FB_SIZE_T size);
5858

@@ -69,24 +69,21 @@ class Guid
6969
"{%08X-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}";
7070
static constexpr int GUID_FORMAT_ARGS = 11;
7171

72-
Guid()
73-
{
74-
memset(&m_data, 0, SIZE);
75-
}
72+
Guid() noexcept {}
7673

7774
public:
7875
static constexpr ULONG SIZE = sizeof(UUID);
7976

80-
static Guid empty()
77+
static Guid empty() noexcept
8178
{
8279
return Guid();
8380
}
8481

85-
Guid(const Guid& other)
82+
Guid(const Guid& other) noexcept
8683
: m_data(other.m_data)
8784
{}
8885

89-
Guid(const UUID& uuid)
86+
Guid(const UUID& uuid) noexcept
9087
: m_data(uuid)
9188
{}
9289

@@ -95,7 +92,7 @@ class Guid
9592
memcpy(&m_data, data, SIZE);
9693
}
9794

98-
Guid& operator=(const Guid& other)
95+
Guid& operator=(const Guid& other) noexcept
9996
{
10097
m_data = other.m_data; // copy struct by value
10198
return *this;
@@ -111,7 +108,7 @@ class Guid
111108
return !(*this == other);
112109
}
113110

114-
const UCHAR* getData() const
111+
const UCHAR* getData() const noexcept
115112
{
116113
return reinterpret_cast<const UCHAR*>(&m_data);
117114
}
@@ -163,7 +160,7 @@ class Guid
163160
return fromString(str.nullStr());
164161
}
165162

166-
void copyTo(UUID& ptr) const
163+
void copyTo(UUID& ptr) const noexcept
167164
{
168165
ptr = m_data; // copy struct by value
169166
}
@@ -175,7 +172,7 @@ class Guid
175172

176173
// Convert platform-dependent GUID into platform-independent form according to RFC 4122
177174

178-
void convert(UCHAR* data) const
175+
void convert(UCHAR* data) const noexcept
179176
{
180177
data[0] = (m_data.Data1 >> 24) & 0xFF;
181178
data[1] = (m_data.Data1 >> 16) & 0xFF;
@@ -205,7 +202,7 @@ class Guid
205202
}
206203

207204
private:
208-
UUID m_data;
205+
UUID m_data{};
209206
};
210207

211208
} // namespace

0 commit comments

Comments
 (0)