diff options
author | dprokoptsev <dprokoptsev@yandex-team.ru> | 2022-02-10 16:50:05 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:05 +0300 |
commit | cf94099c3ea704df29c11dfb77e2adec41a6708d (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 | |
parent | 94e596fdab09d4aeb51a3d27767959d8ed030a3d (diff) | |
download | ydb-cf94099c3ea704df29c11dfb77e2adec41a6708d.tar.gz |
Restoring authorship annotation for <dprokoptsev@yandex-team.ru>. Commit 2 of 2.
-rw-r--r-- | library/cpp/testing/unittest/registar.h | 4 | ||||
-rw-r--r-- | util/charset/wide_ut.cpp | 4 | ||||
-rw-r--r-- | util/generic/maybe.h | 6 | ||||
-rw-r--r-- | util/generic/string.h | 4 | ||||
-rw-r--r-- | util/memory/segmented_string_pool.h | 10 | ||||
-rw-r--r-- | util/stream/aligned.h | 28 | ||||
-rw-r--r-- | util/string/vector.h | 22 | ||||
-rw-r--r-- | util/system/filemap.cpp | 4 | ||||
-rw-r--r-- | util/system/filemap_ut.cpp | 70 | ||||
-rw-r--r-- | util/ysaveload.h | 10 |
10 files changed, 81 insertions, 81 deletions
diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h index f6706bbb84..44517a0092 100644 --- a/library/cpp/testing/unittest/registar.h +++ b/library/cpp/testing/unittest/registar.h @@ -981,7 +981,7 @@ public: \ UNIT_TEST_SUITE_REGISTRATION(TCurrentTest) \ } \ namespace NTestSuite##N - + #define Y_UNIT_TEST_SUITE_IMPL(N, T) Y_UNIT_TEST_SUITE_IMPL_F(N, T, ::NUnitTest::TBaseTestCase) #define Y_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, TTestBase) #define Y_UNIT_TEST_SUITE_F(N, F) Y_UNIT_TEST_SUITE_IMPL_F(N, TTestBase, F) @@ -1006,7 +1006,7 @@ public: \ } \ }; \ static const TTestRegistration##N testRegistration##N; - + #define Y_UNIT_TEST_IMPL(N, FF, F) \ Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \ void TTestCase##N::Execute_(NUnitTest::TTestContext& ut_context Y_DECLARE_UNUSED) diff --git a/util/charset/wide_ut.cpp b/util/charset/wide_ut.cpp index a5c8233e8a..d8f3233e73 100644 --- a/util/charset/wide_ut.cpp +++ b/util/charset/wide_ut.cpp @@ -517,13 +517,13 @@ void TConversionTest::TestUTF8ToWide() { void TConversionTest::TestWideToUTF8() { TString s = WideToUTF8(UnicodeText_); - size_t len = 0; + size_t len = 0; for (TUtf16String::const_iterator i = UnicodeText_.begin(), ie = UnicodeText_.end(); i != ie; ++i) { len += UTF8RuneLenByUCS(*i); } UNIT_ASSERT(s.size() == Utf8Text_.size()); - UNIT_ASSERT(s.size() == len); + UNIT_ASSERT(s.size() == len); for (int i = 0; i < static_cast<int>(s.size()); ++i) { UNIT_ASSERT_VALUES_EQUAL(s[i], Utf8Text_[i]); diff --git a/util/generic/maybe.h b/util/generic/maybe.h index 0d0238f0f6..34d21aebcd 100644 --- a/util/generic/maybe.h +++ b/util/generic/maybe.h @@ -1,5 +1,5 @@ #pragma once - + #include <utility> #include "maybe_traits.h" @@ -36,7 +36,7 @@ constexpr bool operator==(TNothing, TNothing) noexcept { template <class T, class Policy /*= ::NMaybe::TPolicyUndefinedExcept*/> class TMaybe: private TMaybeBase<T> { -public: +public: using TInPlace = NMaybe::TInPlace; private: @@ -446,7 +446,7 @@ private: new (Data()) T(std::forward<Args>(args)...); this->Defined_ = true; } -}; +}; template <class T> using TMaybeFail = TMaybe<T, NMaybe::TPolicyUndefinedFail>; diff --git a/util/generic/string.h b/util/generic/string.h index 55fc99926a..8cd8aa6917 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -311,9 +311,9 @@ public: return &*MutRef().begin(); } - iterator vend() { + iterator vend() { return &*MutRef().end(); - } + } reverse_iterator rbegin() { return reverse_iterator(vend()); diff --git a/util/memory/segmented_string_pool.h b/util/memory/segmented_string_pool.h index 03b6b5d11e..a40aa408f5 100644 --- a/util/memory/segmented_string_pool.h +++ b/util/memory/segmented_string_pool.h @@ -98,12 +98,12 @@ public: size_t get_segment_size() const { return segment_size; } - bool contains(const T* ptr) const { - for (seg_const_iterator i = segs.begin(), ie = segs.end(); i != ie; ++i) + bool contains(const T* ptr) const { + for (seg_const_iterator i = segs.begin(), ie = segs.end(); i != ie; ++i) if ((char*)ptr >= (char*)i->data && (char*)ptr < (char*)i->data + i->freepos) - return true; - return false; - } + return true; + return false; + } size_t size() const { size_t r = 0; for (seg_const_iterator i = segs.begin(); i != segs.end(); ++i) diff --git a/util/stream/aligned.h b/util/stream/aligned.h index 39d17ef827..70e7be05a9 100644 --- a/util/stream/aligned.h +++ b/util/stream/aligned.h @@ -1,8 +1,8 @@ #pragma once - + #include "input.h" #include "output.h" - + #include <util/system/yassert.h> #include <util/generic/bitops.h> @@ -16,12 +16,12 @@ * aligned data easier. */ class TAlignedInput: public IInputStream { -public: +public: TAlignedInput(IInputStream* s) : Stream_(s) , Position_(0) - { - } + { + } /** * Ensures alignment of the position in the input stream by skipping @@ -39,7 +39,7 @@ public: len -= DoSkip(len); } while (len); } - } + } private: size_t DoRead(void* ptr, size_t len) override; @@ -50,19 +50,19 @@ private: private: IInputStream* Stream_; ui64 Position_; -}; - +}; + /** * Proxy output stream that provides additional functions that make writing * aligned data easier. */ class TAlignedOutput: public IOutputStream { -public: +public: TAlignedOutput(IOutputStream* s) : Stream_(s) , Position_(0) - { - } + { + } TAlignedOutput(TAlignedOutput&&) noexcept = default; TAlignedOutput& operator=(TAlignedOutput&&) noexcept = default; @@ -86,7 +86,7 @@ public: if (Position_ & (alignment - 1)) { DoWrite(unused, alignment - (Position_ & (alignment - 1))); } - } + } private: void DoWrite(const void* ptr, size_t len) override; @@ -94,6 +94,6 @@ private: private: IOutputStream* Stream_; ui64 Position_; -}; - +}; + /** @} */ diff --git a/util/string/vector.h b/util/string/vector.h index c706b320b0..e36c348bbe 100644 --- a/util/string/vector.h +++ b/util/string/vector.h @@ -68,19 +68,19 @@ SplitString(const typename ::NPrivate::TStringDeducer<C>::type& str, const C* de template <class TIter> inline TString JoinStrings(TIter begin, TIter end, const TStringBuf delim) { - if (begin == end) + if (begin == end) return TString(); TString result = ToString(*begin); - for (++begin; begin != end; ++begin) { - result.append(delim); + for (++begin; begin != end; ++begin) { + result.append(delim); result.append(ToString(*begin)); - } + } + + return result; +} - return result; -} - template <class TIter> inline TUtf16String JoinStrings(TIter begin, TIter end, const TWtringBuf delim) { if (begin == end) @@ -99,13 +99,13 @@ inline TUtf16String JoinStrings(TIter begin, TIter end, const TWtringBuf delim) /// Concatenates elements of given TVector<TString>. inline TString JoinStrings(const TVector<TString>& v, const TStringBuf delim) { return JoinStrings(v.begin(), v.end(), delim); -} - +} + inline TString JoinStrings(const TVector<TString>& v, size_t index, size_t count, const TStringBuf delim) { Y_ASSERT(index + count <= v.size() && "JoinStrings(): index or count out of range"); return JoinStrings(v.begin() + index, v.begin() + index + count, delim); -} - +} + template <typename T> inline TString JoinVectorIntoString(const TVector<T>& v, const TStringBuf delim) { return JoinStrings(v.begin(), v.end(), delim); diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp index 858539c010..7454a4cb94 100644 --- a/util/system/filemap.cpp +++ b/util/system/filemap.cpp @@ -240,7 +240,7 @@ public: (Mode_ & oAccessMask) == oRdOnly ? FILE_MAP_READ : (Mode_ & oAccessMask) == oCopyOnWr ? FILE_MAP_COPY : FILE_MAP_WRITE, Hi32(base), Lo32(base), size); -#else +#else #if defined(_unix_) if (Mode_ & oNotGreedy) { #endif @@ -272,7 +272,7 @@ public: inline bool Unmap(void* ptr, size_t) { return ::UnmapViewOfFile(ptr) != FALSE; } -#else +#else inline bool Unmap(void* ptr, size_t size) { #if defined(_unix_) if (Mode_ & oNotGreedy) { diff --git a/util/system/filemap_ut.cpp b/util/system/filemap_ut.cpp index 53aee62c01..73f109dc88 100644 --- a/util/system/filemap_ut.cpp +++ b/util/system/filemap_ut.cpp @@ -1,8 +1,8 @@ #include <library/cpp/testing/unittest/registar.h> -#ifdef _unix_ +#ifdef _unix_ #include <sys/resource.h> -#endif +#endif #include "filemap.h" @@ -135,82 +135,82 @@ Y_UNIT_TEST_SUITE(TFileMapTest) { unsigned page[4096 / sizeof(unsigned)]; #if defined(_unix_) - // Temporary limit allowed virtual memory size to 1Gb - struct rlimit rlim; + // Temporary limit allowed virtual memory size to 1Gb + struct rlimit rlim; if (getrlimit(RLIMIT_AS, &rlim)) { - throw TSystemError() << "Cannot get rlimit for virtual memory"; + throw TSystemError() << "Cannot get rlimit for virtual memory"; } rlim_t Limit = 1 * 1024 * 1024 * 1024; - if (rlim.rlim_cur > Limit) { - rlim.rlim_cur = Limit; + if (rlim.rlim_cur > Limit) { + rlim.rlim_cur = Limit; if (setrlimit(RLIMIT_AS, &rlim)) { - throw TSystemError() << "Cannot set rlimit for virtual memory to 1Gb"; + throw TSystemError() << "Cannot set rlimit for virtual memory to 1Gb"; } - } + } #endif - // Make a 128M test file - try { - TFile file(FileName_, CreateAlways | WrOnly); + // Make a 128M test file + try { + TFile file(FileName_, CreateAlways | WrOnly); for (unsigned pages = 128 * 1024 * 1024 / sizeof(page), i = 0; pages--; i++) { std::fill(page, page + sizeof(page) / sizeof(*page), i); - file.Write(page, sizeof(page)); - } + file.Write(page, sizeof(page)); + } - file.Close(); + file.Close(); - // Make 16 maps of our file, which would require 16*128M = 2Gb and exceed our 1Gb limit + // Make 16 maps of our file, which would require 16*128M = 2Gb and exceed our 1Gb limit TVector<THolder<TFileMap>> maps; - for (int i = 0; i < 16; ++i) { + for (int i = 0; i < 16; ++i) { maps.emplace_back(MakeHolder<TFileMap>(FileName_, TMemoryMapCommon::oRdOnly | TMemoryMapCommon::oNotGreedy)); - maps.back()->Map(i * sizeof(page), sizeof(page)); - } + maps.back()->Map(i * sizeof(page), sizeof(page)); + } - // Oh, good, we're not dead yet - for (int i = 0; i < 16; ++i) { - TFileMap& map = *maps[i]; + // Oh, good, we're not dead yet + for (int i = 0; i < 16; ++i) { + TFileMap& map = *maps[i]; UNIT_ASSERT_EQUAL(map.Length(), 128 * 1024 * 1024); - UNIT_ASSERT_EQUAL(map.MappedSize(), sizeof(page)); + UNIT_ASSERT_EQUAL(map.MappedSize(), sizeof(page)); const int* mappedPage = (const int*)map.Ptr(); for (size_t j = 0; j < sizeof(page) / sizeof(*page); ++j) { - UNIT_ASSERT_EQUAL(mappedPage[j], i); + UNIT_ASSERT_EQUAL(mappedPage[j], i); } - } + } #if defined(_unix_) - // Restore limits and cleanup - rlim.rlim_cur = rlim.rlim_max; + // Restore limits and cleanup + rlim.rlim_cur = rlim.rlim_max; if (setrlimit(RLIMIT_AS, &rlim)) { - throw TSystemError() << "Cannot restore rlimit for virtual memory"; + throw TSystemError() << "Cannot restore rlimit for virtual memory"; } #endif - maps.clear(); + maps.clear(); NFs::Remove(FileName_); } catch (...) { // TODO: RAII'ize all this stuff #if defined(_unix_) - rlim.rlim_cur = rlim.rlim_max; + rlim.rlim_cur = rlim.rlim_max; if (setrlimit(RLIMIT_AS, &rlim)) { - throw TSystemError() << "Cannot restore rlimit for virtual memory"; + throw TSystemError() << "Cannot restore rlimit for virtual memory"; } #endif NFs::Remove(FileName_); - throw; - } - } + throw; + } + } #endif - + Y_UNIT_TEST(TestFileMappedArray) { { TFileMappedArray<ui32> mappedArray; diff --git a/util/ysaveload.h b/util/ysaveload.h index 938c82d6ff..02efb4049b 100644 --- a/util/ysaveload.h +++ b/util/ysaveload.h @@ -398,16 +398,16 @@ template <class T, size_t N> class TSerializer<std::array<T, N>>: public TStdArraySerializer<std::array<T, N>> { }; -template <class A, class B> +template <class A, class B> class TSerializer<std::pair<A, B>> { using TPair = std::pair<A, B>; - + public: static inline void Save(IOutputStream* rh, const TPair& p) { ::Save(rh, p.first); ::Save(rh, p.second); } - + static inline void Load(IInputStream* rh, TPair& p) { ::Load(rh, p.first); ::Load(rh, p.second); @@ -418,8 +418,8 @@ public: ::Load(rh, p.first, pool); ::Load(rh, p.second, pool); } -}; - +}; + template <class T> struct TTupleSerializer { template <class F, class Tuple, size_t... Indices> |