diff options
author | risenberg <risenberg@yandex-team.ru> | 2022-02-10 16:49:47 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:47 +0300 |
commit | ec551e975caf33bd88e2803b55464cad608e2441 (patch) | |
tree | d2f84f5b97ecb84201832f831b261817be37fbfe | |
parent | 6a705ee267e43301156c202a4b371d47ddd4dd4f (diff) | |
download | ydb-ec551e975caf33bd88e2803b55464cad608e2441.tar.gz |
Restoring authorship annotation for <risenberg@yandex-team.ru>. Commit 1 of 2.
-rw-r--r-- | library/cpp/containers/comptrie/chunked_helpers_trie.h | 2 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/comptrie_builder.h | 4 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/comptrie_builder.inl | 12 | ||||
-rw-r--r-- | library/cpp/getopt/small/opt.cpp | 2 | ||||
-rw-r--r-- | library/cpp/http/io/stream_ut.cpp | 6 | ||||
-rw-r--r-- | library/cpp/lfalloc/lf_allocX64.h | 10 | ||||
-rw-r--r-- | library/cpp/string_utils/parse_size/parse_size.cpp | 46 | ||||
-rw-r--r-- | library/cpp/string_utils/parse_size/parse_size.h | 16 | ||||
-rw-r--r-- | library/cpp/string_utils/parse_size/parse_size_ut.cpp | 38 | ||||
-rw-r--r-- | util/draft/holder_vector.h | 20 | ||||
-rw-r--r-- | util/draft/holder_vector_ut.cpp | 72 | ||||
-rw-r--r-- | util/folder/path.cpp | 2 | ||||
-rw-r--r-- | util/generic/refcount.h | 46 | ||||
-rw-r--r-- | util/string/cast_ut.cpp | 12 |
14 files changed, 144 insertions, 144 deletions
diff --git a/library/cpp/containers/comptrie/chunked_helpers_trie.h b/library/cpp/containers/comptrie/chunked_helpers_trie.h index cfa35f5ba2..cb6d7dd8f3 100644 --- a/library/cpp/containers/comptrie/chunked_helpers_trie.h +++ b/library/cpp/containers/comptrie/chunked_helpers_trie.h @@ -166,7 +166,7 @@ public: void Save(IOutputStream& out, bool minimize = false) const { if (minimize) { - CompactTrieMinimize<TBuilder>(out, Builder, false); + CompactTrieMinimize<TBuilder>(out, Builder, false); } else { Builder.Save(out); } diff --git a/library/cpp/containers/comptrie/comptrie_builder.h b/library/cpp/containers/comptrie/comptrie_builder.h index cf7d2e39a3..5754b3e70b 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.h +++ b/library/cpp/containers/comptrie/comptrie_builder.h @@ -120,9 +120,9 @@ protected: template <class TPacker> size_t CompactTrieMinimize(IOutputStream& os, const char* data, size_t datalength, bool verbose = false, const TPacker& packer = TPacker(), NCompactTrie::EMinimizeMode mode = NCompactTrie::MM_DEFAULT); -template <class TTrieBuilder> +template <class TTrieBuilder> size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool verbose = false); - + //---------------------------------------------------------------------------------------------------------------- // Lay the trie in memory in such a way that there are less cache misses when jumping from root to leaf. // The trie becomes about 2% larger, but the access became about 25% faster in our experiments. diff --git a/library/cpp/containers/comptrie/comptrie_builder.inl b/library/cpp/containers/comptrie/comptrie_builder.inl index f273fa6571..3f0ba675a4 100644 --- a/library/cpp/containers/comptrie/comptrie_builder.inl +++ b/library/cpp/containers/comptrie/comptrie_builder.inl @@ -1065,13 +1065,13 @@ size_t CompactTrieMinimize(IOutputStream& os, const char* data, size_t datalengt using namespace NCompactTrie; return CompactTrieMinimizeImpl(os, data, datalength, verbose, &packer, mode); } - -template <class TTrieBuilder> + +template <class TTrieBuilder> size_t CompactTrieMinimize(IOutputStream& os, const TTrieBuilder& builder, bool verbose /*=false*/) { - TBufferStream buftmp; - size_t len = builder.Save(buftmp); - return CompactTrieMinimize<typename TTrieBuilder::TPacker>(os, buftmp.Buffer().Data(), len, verbose); -} + TBufferStream buftmp; + size_t len = builder.Save(buftmp); + return CompactTrieMinimize<typename TTrieBuilder::TPacker>(os, buftmp.Buffer().Data(), len, verbose); +} //---------------------------------------------------------------------------------------------------------------- // Lay the trie in memory in such a way that there are less cache misses when jumping from root to leaf. diff --git a/library/cpp/getopt/small/opt.cpp b/library/cpp/getopt/small/opt.cpp index 744501765c..819cbc3633 100644 --- a/library/cpp/getopt/small/opt.cpp +++ b/library/cpp/getopt/small/opt.cpp @@ -20,7 +20,7 @@ void Opt::Init(int argc, char* argv[], const char* optString, const Ion* longOpt Ions_ = longOptions; Err = true; GotError_ = false; - Ind = argc; + Ind = argc; Opts_.Reset(new TOptsNoDefault(optString)); for (const Ion* o = longOptions; o != nullptr && o->name != nullptr; ++o) { diff --git a/library/cpp/http/io/stream_ut.cpp b/library/cpp/http/io/stream_ut.cpp index 1ea35df675..11bbc9abd4 100644 --- a/library/cpp/http/io/stream_ut.cpp +++ b/library/cpp/http/io/stream_ut.cpp @@ -409,16 +409,16 @@ Y_UNIT_TEST_SUITE(THttpStreamTest) { r += "<html>Hello</html>"; TStringInput stringInput(r); THttpInput input(&stringInput); - + const THttpHeaders& httpHeaders = input.Headers(); UNIT_ASSERT_VALUES_EQUAL(httpHeaders.Count(), 3u); - + THttpHeaders::TConstIterator it = httpHeaders.Begin(); UNIT_ASSERT_VALUES_EQUAL(it->ToString(), TString(headerLine1)); UNIT_ASSERT_VALUES_EQUAL((++it)->ToString(), TString::Join(headerLine2, headerLine3)); UNIT_ASSERT_VALUES_EQUAL((++it)->ToString(), TString(headerLine4)); } - + Y_UNIT_TEST(ContentLengthRemoval) { TMemoryInput request("GET / HTTP/1.1\r\nAccept-Encoding: gzip\r\n\r\n"); THttpInput i(&request); diff --git a/library/cpp/lfalloc/lf_allocX64.h b/library/cpp/lfalloc/lf_allocX64.h index fd2a906d6f..cb9dfe2f1d 100644 --- a/library/cpp/lfalloc/lf_allocX64.h +++ b/library/cpp/lfalloc/lf_allocX64.h @@ -300,14 +300,14 @@ enum EMMapMode { MM_NORMAL, // memory for small allocs MM_HUGE // memory for large allocs }; - + #ifndef _MSC_VER -inline void VerifyMmapResult(void* result) { +inline void VerifyMmapResult(void* result) { if (Y_UNLIKELY(result == MAP_FAILED)) NMalloc::AbortFromCorruptedAllocator("negative size requested? or just out of mem"); -} +} #endif - + #if !defined(_MSC_VER) && !defined(_freebsd_) && defined(_64_) static char* AllocWithMMapLinuxImpl(uintptr_t sz, EMMapMode mode) { char* volatile* areaPtr; @@ -349,7 +349,7 @@ static char* AllocWithMMapLinuxImpl(uintptr_t sz, EMMapMode mode) { continue; char* largeBlock = (char*)mmap(prevAllocPtr, sz, mapProt, mapFlags, -1, 0); - VerifyMmapResult(largeBlock); + VerifyMmapResult(largeBlock); if (largeBlock == prevAllocPtr) return largeBlock; if (largeBlock) diff --git a/library/cpp/string_utils/parse_size/parse_size.cpp b/library/cpp/string_utils/parse_size/parse_size.cpp index 39188d560b..a2ed797b36 100644 --- a/library/cpp/string_utils/parse_size/parse_size.cpp +++ b/library/cpp/string_utils/parse_size/parse_size.cpp @@ -3,36 +3,36 @@ #include <util/generic/yexception.h> #include <util/generic/ylimits.h> #include <util/string/cast.h> -#include <util/stream/output.h> +#include <util/stream/output.h> -namespace { +namespace { enum ESuffixShifts { ESS_KILO_BYTES = 10, ESS_MEGA_BYTES = 20, ESS_GIGA_BYTES = 30, ESS_TERA_BYTES = 40, }; - + bool TryShiftValue(ui64& value, ui64 shift) { if (value > (Max<ui64>() >> shift)) { return false; } - + value <<= shift; return true; - } - + } + ui64 ShiftValue(ui64 value, ui64 shift) { if (!TryShiftValue(value, shift)) { ythrow yexception() << "value overflow '" << value << " << " << shift << "'"; } else { return value; } - } - -} - -namespace NSize { + } + +} + +namespace NSize { ui64 ParseSize(TStringBuf str) { if (! str.size()) ythrow yexception() << "Wrong size " << str; @@ -56,7 +56,7 @@ namespace NSize { default: ythrow yexception() << "Unknown suffix " << str; } - + ui64 value = FromString<ui64>(str.substr(0, str.size() - 1)); if (!TryShiftValue(value, shift)) { @@ -77,19 +77,19 @@ namespace NSize { TSize FromGigaBytes(ui64 value) { return TSize(ShiftValue(value, ESS_GIGA_BYTES)); } - + TSize FromTeraBytes(ui64 value) { return TSize(ShiftValue(value, ESS_TERA_BYTES)); } - -} - -template <> -NSize::TSize FromStringImpl<NSize::TSize>(const char* data, size_t len) { - return NSize::TSize(NSize::ParseSize(TStringBuf(data, len))); -} - + +} + template <> +NSize::TSize FromStringImpl<NSize::TSize>(const char* data, size_t len) { + return NSize::TSize(NSize::ParseSize(TStringBuf(data, len))); +} + +template <> void Out<NSize::TSize>(IOutputStream& os, const NSize::TSize& size) { - os << size.GetValue(); -} + os << size.GetValue(); +} diff --git a/library/cpp/string_utils/parse_size/parse_size.h b/library/cpp/string_utils/parse_size/parse_size.h index ad235ef02f..61db957b12 100644 --- a/library/cpp/string_utils/parse_size/parse_size.h +++ b/library/cpp/string_utils/parse_size/parse_size.h @@ -2,9 +2,9 @@ #include <util/generic/strbuf.h> -namespace NSize { +namespace NSize { ui64 ParseSize(TStringBuf size); - + // Convenient disk size representation with string parsing and integer comparison class TSize { public: @@ -12,22 +12,22 @@ namespace NSize { : Value(value) { } - + ui64 GetValue() const { return Value; } - + operator ui64() const { return Value; } - + private: ui64 Value; }; - + TSize FromKiloBytes(ui64 value); TSize FromMegaBytes(ui64 value); TSize FromGigaBytes(ui64 value); TSize FromTeraBytes(ui64 value); - -} + +} diff --git a/library/cpp/string_utils/parse_size/parse_size_ut.cpp b/library/cpp/string_utils/parse_size/parse_size_ut.cpp index 8fff4f56b2..7aae60f9d5 100644 --- a/library/cpp/string_utils/parse_size/parse_size_ut.cpp +++ b/library/cpp/string_utils/parse_size/parse_size_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -using namespace NSize; - +using namespace NSize; + class TParseSizeTest: public TTestBase { UNIT_TEST_SUITE(TParseSizeTest); @@ -12,9 +12,9 @@ class TParseSizeTest: public TTestBase { UNIT_TEST(TestMegaBytes); UNIT_TEST(TestGigaBytes); UNIT_TEST(TestTeraBytes); - UNIT_TEST(TestOverflow); - UNIT_TEST(TestStaticCreators); - UNIT_TEST(TestToString); + UNIT_TEST(TestOverflow); + UNIT_TEST(TestStaticCreators); + UNIT_TEST(TestToString); UNIT_TEST_SUITE_END(); @@ -43,21 +43,21 @@ private: UNIT_ASSERT(ParseSize("10t") == 1024ul * 1024ul * 1024ul * 1024ul * 10ul); } - void TestStaticCreators() { - UNIT_ASSERT_EQUAL(FromKiloBytes(10), 1024ul * 10ul); - UNIT_ASSERT_EQUAL(FromMegaBytes(10), 1024ul * 1024ul * 10ul); - UNIT_ASSERT_EQUAL(FromGigaBytes(10), 1024ul * 1024ul * 1024ul * 10ul); - UNIT_ASSERT_EQUAL(FromTeraBytes(10), 1024ul * 1024ul * 1024ul * 1024ul * 10ul); - } - - void TestOverflow() { - UNIT_ASSERT_EXCEPTION(ParseSize("20000000000G"), yexception); - UNIT_ASSERT_EXCEPTION(FromGigaBytes(20000000000ull), yexception); - } - - void TestToString() { + void TestStaticCreators() { + UNIT_ASSERT_EQUAL(FromKiloBytes(10), 1024ul * 10ul); + UNIT_ASSERT_EQUAL(FromMegaBytes(10), 1024ul * 1024ul * 10ul); + UNIT_ASSERT_EQUAL(FromGigaBytes(10), 1024ul * 1024ul * 1024ul * 10ul); + UNIT_ASSERT_EQUAL(FromTeraBytes(10), 1024ul * 1024ul * 1024ul * 1024ul * 10ul); + } + + void TestOverflow() { + UNIT_ASSERT_EXCEPTION(ParseSize("20000000000G"), yexception); + UNIT_ASSERT_EXCEPTION(FromGigaBytes(20000000000ull), yexception); + } + + void TestToString() { UNIT_ASSERT_VALUES_EQUAL(ToString(FromKiloBytes(1)), TString("1024")); - } + } }; UNIT_TEST_SUITE_REGISTRATION(TParseSizeTest); 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); } }; |