diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:48 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:48 +0300 |
commit | 9abfb1a53b7f7b791444d1378e645d8fad9b06ed (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /util/generic/guid.h | |
parent | 8cbc307de0221f84c80c42dcbe07d40727537e2c (diff) | |
download | ydb-9abfb1a53b7f7b791444d1378e645d8fad9b06ed.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic/guid.h')
-rw-r--r-- | util/generic/guid.h | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/util/generic/guid.h b/util/generic/guid.h index 7c1884d96e..2bf6c8ad99 100644 --- a/util/generic/guid.h +++ b/util/generic/guid.h @@ -1,7 +1,7 @@ #pragma once -#include "fwd.h" - +#include "fwd.h" + #include <util/str_stl.h> /** @@ -15,13 +15,13 @@ * and https://st.yandex-team.ru/IGNIETFERRO-768 for details. */ struct TGUID { - ui32 dw[4] = {}; + ui32 dw[4] = {}; - constexpr bool IsEmpty() const noexcept { + constexpr bool IsEmpty() const noexcept { return (dw[0] | dw[1] | dw[2] | dw[3]) == 0; } - constexpr explicit operator bool() const noexcept { + constexpr explicit operator bool() const noexcept { return !IsEmpty(); } @@ -44,23 +44,23 @@ struct TGUID { static TGUID CreateTimebased(); }; -constexpr bool operator==(const TGUID& a, const TGUID& b) noexcept { - return a.dw[0] == b.dw[0] && a.dw[1] == b.dw[1] && a.dw[2] == b.dw[2] && a.dw[3] == b.dw[3]; +constexpr bool operator==(const TGUID& a, const TGUID& b) noexcept { + return a.dw[0] == b.dw[0] && a.dw[1] == b.dw[1] && a.dw[2] == b.dw[2] && a.dw[3] == b.dw[3]; } -constexpr bool operator!=(const TGUID& a, const TGUID& b) noexcept { +constexpr bool operator!=(const TGUID& a, const TGUID& b) noexcept { return !(a == b); } struct TGUIDHash { - constexpr int operator()(const TGUID& a) const noexcept { + constexpr int operator()(const TGUID& a) const noexcept { return a.dw[0] + a.dw[1] + a.dw[2] + a.dw[3]; } }; template <> struct THash<TGUID> { - constexpr size_t operator()(const TGUID& g) const noexcept { + constexpr size_t operator()(const TGUID& g) const noexcept { return (unsigned int)TGUIDHash()(g); } }; @@ -68,12 +68,12 @@ struct THash<TGUID> { void CreateGuid(TGUID* res); TString GetGuidAsString(const TGUID& g); TString CreateGuidAsString(); -TGUID GetGuid(TStringBuf s); -bool GetGuid(TStringBuf s, TGUID& result); +TGUID GetGuid(TStringBuf s); +bool GetGuid(TStringBuf s, TGUID& result); /** * Functions for correct parsing RFC4122 GUID, which described in * https://en.wikipedia.org/wiki/Universally_unique_identifier **/ -TGUID GetUuid(TStringBuf s); -bool GetUuid(TStringBuf s, TGUID& result); +TGUID GetUuid(TStringBuf s); +bool GetUuid(TStringBuf s, TGUID& result); |