aboutsummaryrefslogtreecommitdiffstats
path: root/util/draft/memory.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/draft/memory.h
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/draft/memory.h')
-rw-r--r--util/draft/memory.h30
1 files changed, 15 insertions, 15 deletions
diff --git a/util/draft/memory.h b/util/draft/memory.h
index 512c7cfcef..0a9722bb36 100644
--- a/util/draft/memory.h
+++ b/util/draft/memory.h
@@ -1,30 +1,30 @@
#pragma once
-#include <util/system/defaults.h>
-
+#include <util/system/defaults.h>
+
#include <algorithm>
#include <functional>
#include <utility>
-template <class T>
-inline bool IsZero(const T* begin, const T* end) {
+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;
+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);
}
-#define IS_ZERO_INTSZ(INT) \
- template <> \
- inline bool IsZero<sizeof(INT)>(const char* p) { \
- return (*(INT*)p) == INT(0); \
- }
+#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)
@@ -34,7 +34,7 @@ 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) {
+template <class T>
+bool IsZero(const T& t) {
return IsZero<sizeof(T)>((const char*)&t);
}