aboutsummaryrefslogtreecommitdiffstats
path: root/util/draft/memory.h
diff options
context:
space:
mode:
authorakhropov <akhropov@yandex-team.ru>2022-02-10 16:46:32 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:32 +0300
commit298c6da79f1d8f35089a67f463f0b541bec36d9b (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/draft/memory.h
parent00afc96e9c0298054b7386fa7fb9e3cc3d67b974 (diff)
downloadydb-298c6da79f1d8f35089a67f463f0b541bec36d9b.tar.gz
Restoring authorship annotation for <akhropov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/draft/memory.h')
-rw-r--r--util/draft/memory.h48
1 files changed, 24 insertions, 24 deletions
diff --git a/util/draft/memory.h b/util/draft/memory.h
index 1f7298d7ec..0a9722bb36 100644
--- a/util/draft/memory.h
+++ b/util/draft/memory.h
@@ -1,40 +1,40 @@
-#pragma once
-
+#pragma once
+
#include <util/system/defaults.h>
-#include <algorithm>
-#include <functional>
-#include <utility>
-
+#include <algorithm>
+#include <functional>
+#include <utility>
+
template <class T>
inline bool IsZero(const T* begin, const T* end) {
return std::find_if(begin, end, [](const T& other) { return other != T(0); }) == end;
-}
-
+}
+
template <size_t Size>
inline bool IsZero(const char* p) {
size_t sizeInUI64 = Size / 8;
const char* pEndUi64 = p + sizeInUI64 * 8;
- if (sizeInUI64 && !IsZero<ui64>((const ui64*)p, (const ui64*)pEndUi64))
- return false;
- return IsZero(pEndUi64, p + Size);
-}
-
+ if (sizeInUI64 && !IsZero<ui64>((const ui64*)p, (const ui64*)pEndUi64))
+ return false;
+ return IsZero(pEndUi64, p + Size);
+}
+
#define IS_ZERO_INTSZ(INT) \
template <> \
inline bool IsZero<sizeof(INT)>(const char* p) { \
return (*(INT*)p) == INT(0); \
}
-
-IS_ZERO_INTSZ(ui8)
-IS_ZERO_INTSZ(ui16)
-IS_ZERO_INTSZ(ui32)
-IS_ZERO_INTSZ(ui64)
-
-#undef IS_ZERO_INTSZ
-
-// If you want to use this to check all fields in a struct make sure it's w/o holes or #pragma pack(1)
+
+IS_ZERO_INTSZ(ui8)
+IS_ZERO_INTSZ(ui16)
+IS_ZERO_INTSZ(ui32)
+IS_ZERO_INTSZ(ui64)
+
+#undef IS_ZERO_INTSZ
+
+// If you want to use this to check all fields in a struct make sure it's w/o holes or #pragma pack(1)
template <class T>
bool IsZero(const T& t) {
- return IsZero<sizeof(T)>((const char*)&t);
-}
+ return IsZero<sizeof(T)>((const char*)&t);
+}