aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorrisenberg <risenberg@yandex-team.ru>2022-02-10 16:49:47 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:47 +0300
commitec551e975caf33bd88e2803b55464cad608e2441 (patch)
treed2f84f5b97ecb84201832f831b261817be37fbfe /util
parent6a705ee267e43301156c202a4b371d47ddd4dd4f (diff)
downloadydb-ec551e975caf33bd88e2803b55464cad608e2441.tar.gz
Restoring authorship annotation for <risenberg@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/draft/holder_vector.h20
-rw-r--r--util/draft/holder_vector_ut.cpp72
-rw-r--r--util/folder/path.cpp2
-rw-r--r--util/generic/refcount.h46
-rw-r--r--util/string/cast_ut.cpp12
5 files changed, 76 insertions, 76 deletions
diff --git a/util/draft/holder_vector.h b/util/draft/holder_vector.h
index 1c62055bd9..e7d8d383bc 100644
--- a/util/draft/holder_vector.h
+++ b/util/draft/holder_vector.h
@@ -9,11 +9,11 @@ class THolderVector: public TVector<T*>, public TNonCopyable {
using TBase = TVector<T*>;
public:
- explicit THolderVector(size_t n = 0)
+ explicit THolderVector(size_t n = 0)
: TBase(n)
{
- }
-
+ }
+
~THolderVector() {
Clear();
}
@@ -50,14 +50,14 @@ public:
}
void Reset(size_t i, THolder<T> t) {
- T* current = (*this)[i];
- if (current) {
+ T* current = (*this)[i];
+ if (current) {
Y_ASSERT(current != t.Get());
- D::Destroy(current);
- }
- (*this)[i] = t.Release();
- }
-
+ D::Destroy(current);
+ }
+ (*this)[i] = t.Release();
+ }
+
void PopBack() {
if (size()) {
D::Destroy(back());
diff --git a/util/draft/holder_vector_ut.cpp b/util/draft/holder_vector_ut.cpp
index f64393860a..b933a10d9b 100644
--- a/util/draft/holder_vector_ut.cpp
+++ b/util/draft/holder_vector_ut.cpp
@@ -1,54 +1,54 @@
-#include "holder_vector.h"
-
+#include "holder_vector.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
+
Y_UNIT_TEST_SUITE(THolderVectorTest) {
Y_UNIT_TEST(TestCreateEmpty) {
- THolderVector<int> ints;
- UNIT_ASSERT_EQUAL(ints.Size(), 0);
+ THolderVector<int> ints;
+ UNIT_ASSERT_EQUAL(ints.Size(), 0);
UNIT_ASSERT(!ints);
- }
-
+ }
+
Y_UNIT_TEST(TestCreateNonEmpty) {
- THolderVector<int> ints(5);
- UNIT_ASSERT_EQUAL(ints.Size(), 5);
+ THolderVector<int> ints(5);
+ UNIT_ASSERT_EQUAL(ints.Size(), 5);
UNIT_ASSERT(ints);
-
- for (size_t i = 0; i < ints.Size(); ++i) {
+
+ for (size_t i = 0; i < ints.Size(); ++i) {
UNIT_ASSERT_EQUAL(ints[i], (int*)nullptr);
- }
- }
-
+ }
+ }
+
Y_UNIT_TEST(TestResetValue) {
- THolderVector<int> ints;
- ints.PushBack(new int(0));
- ints.PushBack(new int(1));
- UNIT_ASSERT_VALUES_EQUAL(*ints[0], 0);
- UNIT_ASSERT_VALUES_EQUAL(*ints[1], 1);
+ THolderVector<int> ints;
+ ints.PushBack(new int(0));
+ ints.PushBack(new int(1));
+ UNIT_ASSERT_VALUES_EQUAL(*ints[0], 0);
+ UNIT_ASSERT_VALUES_EQUAL(*ints[1], 1);
ints.Reset(0, MakeHolder<int>(2));
ints.Reset(1, MakeHolder<int>(3));
- UNIT_ASSERT_VALUES_EQUAL(*ints[0], 2);
- UNIT_ASSERT_VALUES_EQUAL(*ints[1], 3);
- }
-
+ UNIT_ASSERT_VALUES_EQUAL(*ints[0], 2);
+ UNIT_ASSERT_VALUES_EQUAL(*ints[1], 3);
+ }
+
Y_UNIT_TEST(TestResetNoValue) {
- THolderVector<int> ints;
- ints.Resize(1);
+ THolderVector<int> ints;
+ ints.Resize(1);
UNIT_ASSERT_EQUAL(ints[0], (int*)nullptr);
ints.Reset(0, MakeHolder<int>(1));
UNIT_ASSERT_UNEQUAL(ints[0], (int*)nullptr);
- UNIT_ASSERT_VALUES_EQUAL(*ints[0], 1);
- }
-
+ UNIT_ASSERT_VALUES_EQUAL(*ints[0], 1);
+ }
+
Y_UNIT_TEST(TestResetSmartPtr) {
- THolderVector<int> ints;
- ints.Resize(2);
-
- THolder<int> holder(new int(1));
+ THolderVector<int> ints;
+ ints.Resize(2);
+
+ THolder<int> holder(new int(1));
ints.Reset(0, std::move(holder));
- UNIT_ASSERT_VALUES_EQUAL(*ints[0], 1);
- UNIT_ASSERT(!holder);
- }
+ UNIT_ASSERT_VALUES_EQUAL(*ints[0], 1);
+ UNIT_ASSERT(!holder);
+ }
Y_UNIT_TEST(TestSwap) {
THolderVector<int> v1;
@@ -66,4 +66,4 @@ Y_UNIT_TEST_SUITE(THolderVectorTest) {
UNIT_ASSERT(v.Size() == 1);
UNIT_ASSERT(str.get() == nullptr);
}
-}
+}
diff --git a/util/folder/path.cpp b/util/folder/path.cpp
index bfe0c67d68..3f37cb5942 100644
--- a/util/folder/path.cpp
+++ b/util/folder/path.cpp
@@ -470,7 +470,7 @@ template <>
void Out<TFsPath>(IOutputStream& os, const TFsPath& f) {
os << f.GetPath();
}
-
+
template <>
TFsPath FromStringImpl<TFsPath>(const char* s, size_t len) {
return TFsPath{TStringBuf{s, len}};
diff --git a/util/generic/refcount.h b/util/generic/refcount.h
index 966e853b77..d6b857e6c1 100644
--- a/util/generic/refcount.h
+++ b/util/generic/refcount.h
@@ -8,7 +8,7 @@
template <class TCounterCheckPolicy>
class TSimpleCounterTemplate: public TCounterCheckPolicy {
using TCounterCheckPolicy::Check;
-
+
public:
inline TSimpleCounterTemplate(long initial = 0) noexcept
: Counter_(initial)
@@ -54,41 +54,41 @@ public:
private:
TAtomicBase Counter_;
-};
-
-class TNoCheckPolicy {
-protected:
- inline void Check() const {
- }
-};
-
+};
+
+class TNoCheckPolicy {
+protected:
+ inline void Check() const {
+ }
+};
+
#if defined(SIMPLE_COUNTER_THREAD_CHECK)
#include <util/system/thread.i>
-class TCheckPolicy {
-public:
- inline TCheckPolicy() {
- ThreadId = SystemCurrentThreadId();
- }
+class TCheckPolicy {
+public:
+ inline TCheckPolicy() {
+ ThreadId = SystemCurrentThreadId();
+ }
-protected:
- inline void Check() const {
+protected:
+ inline void Check() const {
Y_VERIFY(ThreadId == SystemCurrentThreadId(), "incorrect usage of TSimpleCounter");
- }
+ }
-private:
- size_t ThreadId;
-};
+private:
+ size_t ThreadId;
+};
#else
using TCheckPolicy = TNoCheckPolicy;
#endif
-// Use this one if access from multiple threads to your pointer is an error and you want to enforce thread checks
+// Use this one if access from multiple threads to your pointer is an error and you want to enforce thread checks
using TSimpleCounter = TSimpleCounterTemplate<TCheckPolicy>;
-// Use this one if you do want to share the pointer between threads, omit thread checks and do the synchronization yourself
+// Use this one if you do want to share the pointer between threads, omit thread checks and do the synchronization yourself
using TExplicitSimpleCounter = TSimpleCounterTemplate<TNoCheckPolicy>;
-
+
template <class TCounterCheckPolicy>
struct TCommonLockOps<TSimpleCounterTemplate<TCounterCheckPolicy>> {
static inline void Acquire(TSimpleCounterTemplate<TCounterCheckPolicy>* t) noexcept {
diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp
index 033450c38c..adc9be1ab5 100644
--- a/util/string/cast_ut.cpp
+++ b/util/string/cast_ut.cpp
@@ -80,12 +80,12 @@ struct TRet {
template <class B>
inline void CheckTryFail(B v) {
- static const A defaultV = 42;
+ static const A defaultV = 42;
A convV = defaultV; // to check that original value is not trashed on bad cast
UNIT_ASSERT_VALUES_EQUAL(TryFromString<A>(ToString(v), convV), false); // char
- UNIT_ASSERT_VALUES_EQUAL(defaultV, convV);
+ UNIT_ASSERT_VALUES_EQUAL(defaultV, convV);
UNIT_ASSERT_VALUES_EQUAL(TryFromString<A>(ToWtring(v), convV), false); // wide char
- UNIT_ASSERT_VALUES_EQUAL(defaultV, convV);
+ UNIT_ASSERT_VALUES_EQUAL(defaultV, convV);
TRY_HEX_MACROS_MAP(TRY_FAIL_HEX_CHECK, A, v, convV, defaultV);
}
@@ -112,10 +112,10 @@ struct TRet<bool> {
template <class B>
inline void CheckTryFail(B v) {
- static const bool defaultV = false;
- bool convV = defaultV;
+ static const bool defaultV = false;
+ bool convV = defaultV;
UNIT_ASSERT_VALUES_EQUAL(TryFromString<bool>(ToString(v), convV), false);
- UNIT_ASSERT_VALUES_EQUAL(defaultV, convV);
+ UNIT_ASSERT_VALUES_EQUAL(defaultV, convV);
}
};