aboutsummaryrefslogtreecommitdiffstats
path: root/util/memory
diff options
context:
space:
mode:
authorswarmer <swarmer@yandex-team.ru>2022-02-10 16:46:31 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:31 +0300
commit11a24635da4c4f39428b182c49a7bc35e47c9534 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/memory
parent317da38588b7898a99fd9168571408123350012b (diff)
downloadydb-11a24635da4c4f39428b182c49a7bc35e47c9534.tar.gz
Restoring authorship annotation for <swarmer@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/memory')
-rw-r--r--util/memory/addstorage.h74
-rw-r--r--util/memory/benchmark/pool/metrics/ya.make2
-rw-r--r--util/memory/benchmark/pool/ya.make2
-rw-r--r--util/memory/benchmark/ya.make2
-rw-r--r--util/memory/blob.h12
-rw-r--r--util/memory/ut/ya.make2
-rw-r--r--util/memory/ya.make10
7 files changed, 52 insertions, 52 deletions
diff --git a/util/memory/addstorage.h b/util/memory/addstorage.h
index 81c8260b9d..597c73a988 100644
--- a/util/memory/addstorage.h
+++ b/util/memory/addstorage.h
@@ -5,40 +5,40 @@
#include <new>
-namespace NPrivate {
- class TAdditionalStorageInfo {
+namespace NPrivate {
+ class TAdditionalStorageInfo {
public:
- constexpr TAdditionalStorageInfo(size_t length) noexcept
- : Length_(length)
- {
+ constexpr TAdditionalStorageInfo(size_t length) noexcept
+ : Length_(length)
+ {
}
- constexpr size_t Length() const noexcept {
- return Length_;
+ constexpr size_t Length() const noexcept {
+ return Length_;
}
private:
- size_t Length_;
+ size_t Length_;
};
-}
+}
+
+template <class T>
+class alignas(::NPrivate::TAdditionalStorageInfo) TAdditionalStorage {
+ using TInfo = ::NPrivate::TAdditionalStorageInfo;
-template <class T>
-class alignas(::NPrivate::TAdditionalStorageInfo) TAdditionalStorage {
- using TInfo = ::NPrivate::TAdditionalStorageInfo;
-
public:
inline TAdditionalStorage() noexcept = default;
inline ~TAdditionalStorage() = default;
inline void* operator new(size_t len1, size_t len2) {
- static_assert(alignof(T) >= alignof(TInfo));
- Y_ASSERT(len1 == sizeof(T));
- void* data = ::operator new(CombinedSizeOfInstanceWithTInfo() + len2);
- void* info = InfoPtr(static_cast<T*>(data));
- Y_UNUSED(new (info) TInfo(len2));
+ static_assert(alignof(T) >= alignof(TInfo));
+ Y_ASSERT(len1 == sizeof(T));
+ void* data = ::operator new(CombinedSizeOfInstanceWithTInfo() + len2);
+ void* info = InfoPtr(static_cast<T*>(data));
+ Y_UNUSED(new (info) TInfo(len2));
- return data;
+ return data;
}
inline void operator delete(void* ptr) noexcept {
@@ -58,36 +58,36 @@ public:
}
inline void* AdditionalData() const noexcept {
- return (char*)(static_cast<const T*>(this)) + CombinedSizeOfInstanceWithTInfo();
+ return (char*)(static_cast<const T*>(this)) + CombinedSizeOfInstanceWithTInfo();
}
static inline T* ObjectFromData(void* data) noexcept {
- return reinterpret_cast<T*>(static_cast<char*>(data) - CombinedSizeOfInstanceWithTInfo());
+ return reinterpret_cast<T*>(static_cast<char*>(data) - CombinedSizeOfInstanceWithTInfo());
}
inline size_t AdditionalDataLength() const noexcept {
- return InfoPtr(static_cast<const T*>(this))->Length();
+ return InfoPtr(static_cast<const T*>(this))->Length();
}
private:
static inline void DoDelete(void* ptr) noexcept {
- TInfo* info = InfoPtr(static_cast<T*>(ptr));
+ TInfo* info = InfoPtr(static_cast<T*>(ptr));
info->~TInfo();
- ::operator delete(ptr);
+ ::operator delete(ptr);
+ }
+
+ static constexpr size_t CombinedSizeOfInstanceWithTInfo() noexcept {
+ return AlignUp(sizeof(T), alignof(TInfo)) + sizeof(TInfo);
+ }
+
+ static constexpr TInfo* InfoPtr(T* instance) noexcept {
+ return const_cast<TInfo*>(InfoPtr(static_cast<const T*>(instance)));
+ }
+
+ static constexpr const TInfo* InfoPtr(const T* instance) noexcept {
+ return reinterpret_cast<const TInfo*>(reinterpret_cast<const char*>(instance) + CombinedSizeOfInstanceWithTInfo() - sizeof(TInfo));
}
- static constexpr size_t CombinedSizeOfInstanceWithTInfo() noexcept {
- return AlignUp(sizeof(T), alignof(TInfo)) + sizeof(TInfo);
- }
-
- static constexpr TInfo* InfoPtr(T* instance) noexcept {
- return const_cast<TInfo*>(InfoPtr(static_cast<const T*>(instance)));
- }
-
- static constexpr const TInfo* InfoPtr(const T* instance) noexcept {
- return reinterpret_cast<const TInfo*>(reinterpret_cast<const char*>(instance) + CombinedSizeOfInstanceWithTInfo() - sizeof(TInfo));
- }
-
private:
- void* operator new(size_t) = delete;
+ void* operator new(size_t) = delete;
};
diff --git a/util/memory/benchmark/pool/metrics/ya.make b/util/memory/benchmark/pool/metrics/ya.make
index 5dcd3f8343..c671bc5c1c 100644
--- a/util/memory/benchmark/pool/metrics/ya.make
+++ b/util/memory/benchmark/pool/metrics/ya.make
@@ -1,5 +1,5 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
PY2TEST()
diff --git a/util/memory/benchmark/pool/ya.make b/util/memory/benchmark/pool/ya.make
index 85199aa3af..5f4f7d3f15 100644
--- a/util/memory/benchmark/pool/ya.make
+++ b/util/memory/benchmark/pool/ya.make
@@ -1,5 +1,5 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
Y_BENCHMARK()
diff --git a/util/memory/benchmark/ya.make b/util/memory/benchmark/ya.make
index 0fe18aae9d..2259b9434e 100644
--- a/util/memory/benchmark/ya.make
+++ b/util/memory/benchmark/ya.make
@@ -1,5 +1,5 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
RECURSE(
pool
diff --git a/util/memory/blob.h b/util/memory/blob.h
index d13b2d3db4..20c02a68df 100644
--- a/util/memory/blob.h
+++ b/util/memory/blob.h
@@ -74,12 +74,12 @@ public:
Ref();
}
- TBlob(TBlob&& r) noexcept
- : TBlob()
- {
- this->Swap(r);
- }
-
+ TBlob(TBlob&& r) noexcept
+ : TBlob()
+ {
+ this->Swap(r);
+ }
+
inline TBlob(const void* data, size_t length, TBase* base) noexcept
: S_(data, length, base)
{
diff --git a/util/memory/ut/ya.make b/util/memory/ut/ya.make
index 69ec434d04..d3a988617d 100644
--- a/util/memory/ut/ya.make
+++ b/util/memory/ut/ya.make
@@ -1,7 +1,7 @@
UNITTEST_FOR(util)
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
+SUBSCRIBER(g:util-subscribers)
SRCS(
memory/addstorage_ut.cpp
diff --git a/util/memory/ya.make b/util/memory/ya.make
index 24723ab579..79c9498ddd 100644
--- a/util/memory/ya.make
+++ b/util/memory/ya.make
@@ -1,6 +1,6 @@
OWNER(g:util)
-SUBSCRIBER(g:util-subscribers)
-
-RECURSE_FOR_TESTS(
- ut
-)
+SUBSCRIBER(g:util-subscribers)
+
+RECURSE_FOR_TESTS(
+ ut
+)