diff options
author | ekrokhalev <ekrokhalev@yandex-team.ru> | 2022-02-10 16:50:10 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:10 +0300 |
commit | 1c01ed5294724fda060c1f0bd674b315fe249598 (patch) | |
tree | c21292982d2c8182cdf5753f9a49e7cda547f4d3 | |
parent | 9991a6195dee8db26aa7e2f5f21549fb20e25002 (diff) | |
download | ydb-1c01ed5294724fda060c1f0bd674b315fe249598.tar.gz |
Restoring authorship annotation for <ekrokhalev@yandex-team.ru>. Commit 1 of 2.
-rw-r--r-- | library/cpp/accurate_accumulate/accurate_accumulate.h | 30 | ||||
-rw-r--r-- | library/cpp/cgiparam/cgiparam_ut.cpp | 20 | ||||
-rw-r--r-- | library/cpp/deprecated/split/delim_string_iter.h | 10 | ||||
-rw-r--r-- | library/cpp/getopt/small/opt2.cpp | 12 | ||||
-rw-r--r-- | library/cpp/getopt/small/opt2.h | 4 | ||||
-rw-r--r-- | util/charset/unidata.h | 36 | ||||
-rw-r--r-- | util/generic/xrange.h | 94 | ||||
-rw-r--r-- | util/generic/xrange_ut.cpp | 46 | ||||
-rw-r--r-- | util/stream/pipe.cpp | 56 | ||||
-rw-r--r-- | util/stream/pipe.h | 18 |
10 files changed, 163 insertions, 163 deletions
diff --git a/library/cpp/accurate_accumulate/accurate_accumulate.h b/library/cpp/accurate_accumulate/accurate_accumulate.h index dacced17e9..b90ea2f4d2 100644 --- a/library/cpp/accurate_accumulate/accurate_accumulate.h +++ b/library/cpp/accurate_accumulate/accurate_accumulate.h @@ -42,24 +42,24 @@ public: template <typename TFloatType> inline bool operator<(const TKahanAccumulator<TFloatType>& other) const { return Get() < other.Get(); - } - - template <typename TFloatType> + } + + template <typename TFloatType> inline bool operator<=(const TKahanAccumulator<TFloatType>& other) const { - return !(other < *this); - } - - template <typename TFloatType> + return !(other < *this); + } + + template <typename TFloatType> inline bool operator>(const TKahanAccumulator<TFloatType>& other) const { - return other < *this; - } - - template <typename TFloatType> + return other < *this; + } + + template <typename TFloatType> inline bool operator>=(const TKahanAccumulator<TFloatType>& other) const { - return !(*this < other); - } - - template <typename TFloatType> + return !(*this < other); + } + + template <typename TFloatType> inline TKahanAccumulator& operator+=(const TFloatType x) { const TValueType y = TValueType(x) - Compensation_; const TValueType t = Sum_ + y; diff --git a/library/cpp/cgiparam/cgiparam_ut.cpp b/library/cpp/cgiparam/cgiparam_ut.cpp index a562342084..01edd0324c 100644 --- a/library/cpp/cgiparam/cgiparam_ut.cpp +++ b/library/cpp/cgiparam/cgiparam_ut.cpp @@ -205,16 +205,16 @@ Y_UNIT_TEST_SUITE(TCgiParametersTest) { Y_UNIT_TEST(TestContInit) { TCgiParameters c = {std::make_pair("a", "a1"), std::make_pair("b", "b1"), std::make_pair("a", "a2")}; - - UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("a"), 2u); - UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("b"), 1u); - - UNIT_ASSERT_VALUES_EQUAL(c.Get("b"), "b1"); - UNIT_ASSERT_VALUES_EQUAL(c.Get("a", 0), "a1"); - UNIT_ASSERT_VALUES_EQUAL(c.Get("a", 1), "a2"); - - UNIT_ASSERT_VALUES_EQUAL(c.Print(), "a=a1&a=a2&b=b1"); - } + + UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("a"), 2u); + UNIT_ASSERT_VALUES_EQUAL(c.NumOfValues("b"), 1u); + + UNIT_ASSERT_VALUES_EQUAL(c.Get("b"), "b1"); + UNIT_ASSERT_VALUES_EQUAL(c.Get("a", 0), "a1"); + UNIT_ASSERT_VALUES_EQUAL(c.Get("a", 1), "a2"); + + UNIT_ASSERT_VALUES_EQUAL(c.Print(), "a=a1&a=a2&b=b1"); + } Y_UNIT_TEST(TestPrintAsQuote) { TCgiParameters c = { diff --git a/library/cpp/deprecated/split/delim_string_iter.h b/library/cpp/deprecated/split/delim_string_iter.h index 8e4ca171a0..8bf66ce943 100644 --- a/library/cpp/deprecated/split/delim_string_iter.h +++ b/library/cpp/deprecated/split/delim_string_iter.h @@ -22,13 +22,13 @@ public: } inline TDelimStringIter(TStringBuf str, TStringBuf delim) - : IsValid(true) + : IsValid(true) , Str(str) - , Delim(delim) - { + , Delim(delim) + { UpdateCurrent(); - } - + } + inline TDelimStringIter() : IsValid(false) { diff --git a/library/cpp/getopt/small/opt2.cpp b/library/cpp/getopt/small/opt2.cpp index 0cdc774e78..1ce2741c86 100644 --- a/library/cpp/getopt/small/opt2.cpp +++ b/library/cpp/getopt/small/opt2.cpp @@ -248,13 +248,13 @@ unsigned long Opt2::UInt(char opt, const char* help, unsigned long def, bool req return rv; } -// Add user defined error message and set error flag -void Opt2::AddError(const char* message) { - HasErrors = true; +// Add user defined error message and set error flag +void Opt2::AddError(const char* message) { + HasErrors = true; if (message) - UserErrorMessages.push_back(message); -} - + UserErrorMessages.push_back(message); +} + int Opt2::AutoUsage(const char* free_arg_names) { if (!HasErrors) return 0; diff --git a/library/cpp/getopt/small/opt2.h b/library/cpp/getopt/small/opt2.h index 4d9d943237..84198c1aba 100644 --- a/library/cpp/getopt/small/opt2.h +++ b/library/cpp/getopt/small/opt2.h @@ -107,9 +107,9 @@ public: // For options w/o parameters bool Has(char opt, const char* helpUsage); - // Add user defined error message and set error flag + // Add user defined error message and set error flag void AddError(const char* message = nullptr); - + public: // non-option args TVector<char*> Pos; diff --git a/util/charset/unidata.h b/util/charset/unidata.h index 400d314186..f4d5a82f0d 100644 --- a/util/charset/unidata.h +++ b/util/charset/unidata.h @@ -400,22 +400,22 @@ inline bool IsPrint(wchar32 ch) { return IsAlnum(ch) || IsPunct(ch) || IsSymbol(ch) || IsBlank(ch); } -inline bool IsRomanDigit(wchar32 ch) { - if (NUnicode::CharHasType(ch, SHIFT(Nl_LETTER)) && 0x2160 <= ch && ch <= 0x2188) - return true; - if (ch < 127) { - switch (static_cast<char>(::ToLower(ch))) { - case 'i': - case 'v': - case 'x': - case 'l': - case 'c': - case 'd': - case 'm': - return true; - } - } - return false; -} - +inline bool IsRomanDigit(wchar32 ch) { + if (NUnicode::CharHasType(ch, SHIFT(Nl_LETTER)) && 0x2160 <= ch && ch <= 0x2188) + return true; + if (ch < 127) { + switch (static_cast<char>(::ToLower(ch))) { + case 'i': + case 'v': + case 'x': + case 'l': + case 'c': + case 'd': + case 'm': + return true; + } + } + return false; +} + #undef SHIFT diff --git a/util/generic/xrange.h b/util/generic/xrange.h index 5fc8c82912..95864d65a3 100644 --- a/util/generic/xrange.h +++ b/util/generic/xrange.h @@ -20,7 +20,7 @@ namespace NPrivate { template <typename T> - class TSimpleXRange { + class TSimpleXRange { using TDiff = decltype(T() - T()); public: @@ -125,21 +125,21 @@ namespace NPrivate { T Finish; }; - template <typename T> - class TSteppedXRange { - using TDiff = decltype(T() - T()); + template <typename T> + class TSteppedXRange { + using TDiff = decltype(T() - T()); - public: + public: constexpr TSteppedXRange(T start, T finish, TDiff step) noexcept : Start_(start) , Step_(step) , Finish_(CalcRealFinish(Start_, finish, Step_)) { static_assert(std::is_integral<T>::value || std::is_pointer<T>::value, "T should be integral type or pointer"); - } - + } + class TIterator { - public: + public: using value_type = T; using difference_type = TDiff; using pointer = const T*; @@ -150,16 +150,16 @@ namespace NPrivate { : Value_(value) , Parent_(&parent) { - } - + } + constexpr T operator*() const noexcept { - return Value_; - } - + return Value_; + } + constexpr bool operator!=(const TIterator& other) const noexcept { - return Value_ != other.Value_; - } - + return Value_ != other.Value_; + } + constexpr bool operator==(const TIterator& other) const noexcept { return Value_ == other.Value_; } @@ -167,8 +167,8 @@ namespace NPrivate { TIterator& operator++() noexcept { Value_ += Parent_->Step_; return *this; - } - + } + TIterator& operator--() noexcept { Value_ -= Parent_->Step_; return *this; @@ -200,34 +200,34 @@ namespace NPrivate { return *this; } - private: - T Value_; + private: + T Value_; const TSteppedXRange* Parent_; - }; - + }; + using value_type = T; using iterator = TIterator; using const_iterator = TIterator; constexpr TIterator begin() const noexcept { - return TIterator(Start_, *this); - } - + return TIterator(Start_, *this); + } + constexpr TIterator end() const noexcept { - return TIterator(Finish_, *this); - } - - static T CalcRealFinish(T start, T expFinish, TDiff step) { + return TIterator(Finish_, *this); + } + + static T CalcRealFinish(T start, T expFinish, TDiff step) { Y_ASSERT(step != 0); - if (step > 0) { - if (expFinish > start) { - return start + step * ((expFinish - 1 - start) / step + 1); - } - return start; - } - return start - TSteppedXRange<TDiff>::CalcRealFinish(0, start - expFinish, -step); - } - + if (step > 0) { + if (expFinish > start) { + return start + step * ((expFinish - 1 - start) / step + 1); + } + return start; + } + return start - TSteppedXRange<TDiff>::CalcRealFinish(0, start - expFinish, -step); + } + constexpr T size() const noexcept { return (Finish_ - Start_) / Step_; } @@ -237,12 +237,12 @@ namespace NPrivate { return Container(begin(), end()); } - private: - const T Start_; - const TDiff Step_; - const T Finish_; - }; - + private: + const T Start_; + const TDiff Step_; + const T Finish_; + }; + } /** @@ -250,11 +250,11 @@ namespace NPrivate { * * @param step must be non-zero */ -template <typename T> +template <typename T> constexpr ::NPrivate::TSteppedXRange<T> xrange(T start, T finish, decltype(T() - T()) step) noexcept { return {start, finish, step}; -} - +} + /// generate sequence [start; finish) template <typename T> constexpr ::NPrivate::TSimpleXRange<T> xrange(T start, T finish) noexcept { diff --git a/util/generic/xrange_ut.cpp b/util/generic/xrange_ut.cpp index 8106da03e7..6f870e9d40 100644 --- a/util/generic/xrange_ut.cpp +++ b/util/generic/xrange_ut.cpp @@ -31,26 +31,26 @@ Y_UNIT_TEST_SUITE(XRange) { } void TestSteppedXRangeImpl(int begin, int end, int step, const TVector<int>& expected) { - size_t expInd = 0; + size_t expInd = 0; for (auto i : xrange(begin, end, step)) { - UNIT_ASSERT(expInd < expected.size()); - UNIT_ASSERT_VALUES_EQUAL(i, expected[expInd]); - ++expInd; - } - UNIT_ASSERT_VALUES_EQUAL(expInd, expected.size()); - } - + UNIT_ASSERT(expInd < expected.size()); + UNIT_ASSERT_VALUES_EQUAL(i, expected[expInd]); + ++expInd; + } + UNIT_ASSERT_VALUES_EQUAL(expInd, expected.size()); + } + Y_UNIT_TEST(IncrementWorks) { TestXRangeImpl(0, 10); TestXRangeImpl(10, 20); } - + Y_UNIT_TEST(DecrementWorks) { TestSteppedXRangeImpl(10, 0, -1, {10, 9, 8, 7, 6, 5, 4, 3, 2, 1}); TestSteppedXRangeImpl(10, -1, -1, {10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}); TestSteppedXRangeImpl(20, 9, -1, {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10}); - } - + } + Y_UNIT_TEST(StepWorks) { TestSteppedXRangeImpl(0, 0, 1, {}); TestSteppedXRangeImpl(0, 9, 3, {0, 3, 6}); @@ -62,22 +62,22 @@ Y_UNIT_TEST_SUITE(XRange) { TestSteppedXRangeImpl(15, 0, -4, {15, 11, 7, 3}); TestSteppedXRangeImpl(15, -1, -4, {15, 11, 7, 3}); TestSteppedXRangeImpl(15, -2, -4, {15, 11, 7, 3, -1}); - } - + } + Y_UNIT_TEST(PointersWorks) { TVector<size_t> data = {3, 1, 4, 1, 5, 9, 2, 6}; - const size_t digSumExpected = Accumulate(data.begin(), data.end(), static_cast<size_t>(0)); - size_t digSumByIt = 0; + const size_t digSumExpected = Accumulate(data.begin(), data.end(), static_cast<size_t>(0)); + size_t digSumByIt = 0; for (auto ptr : xrange(data.begin(), data.end())) { - digSumByIt += *ptr; - } - UNIT_ASSERT_VALUES_EQUAL(digSumByIt, digSumExpected); - size_t digSumByPtr = 0; + digSumByIt += *ptr; + } + UNIT_ASSERT_VALUES_EQUAL(digSumByIt, digSumExpected); + size_t digSumByPtr = 0; for (auto ptr : xrange(&data[0], &data[0] + data.size())) { - digSumByPtr += *ptr; - } - UNIT_ASSERT_VALUES_EQUAL(digSumByPtr, digSumExpected); - } + digSumByPtr += *ptr; + } + UNIT_ASSERT_VALUES_EQUAL(digSumByPtr, digSumExpected); + } Y_UNIT_TEST(SizeMethodCheck) { UNIT_ASSERT_VALUES_EQUAL(xrange(5).size(), 5); diff --git a/util/stream/pipe.cpp b/util/stream/pipe.cpp index 51be1934a7..556c5766d7 100644 --- a/util/stream/pipe.cpp +++ b/util/stream/pipe.cpp @@ -82,40 +82,40 @@ void TPipeOutput::Close() { } } -TPipedBase::TPipedBase(PIPEHANDLE fd) - : Handle_(fd) -{ -} - +TPipedBase::TPipedBase(PIPEHANDLE fd) + : Handle_(fd) +{ +} + TPipedBase::~TPipedBase() { if (Handle_.IsOpen()) { - Handle_.Close(); + Handle_.Close(); } -} - +} + TPipedInput::TPipedInput(PIPEHANDLE fd) - : TPipedBase(fd) -{ -} - + : TPipedBase(fd) +{ +} + TPipedInput::~TPipedInput() = default; - -size_t TPipedInput::DoRead(void* buf, size_t len) { + +size_t TPipedInput::DoRead(void* buf, size_t len) { if (!Handle_.IsOpen()) { - return 0; + return 0; } return Handle_.Read(buf, len); -} - -TPipedOutput::TPipedOutput(PIPEHANDLE fd) - : TPipedBase(fd) -{ -} - +} + +TPipedOutput::TPipedOutput(PIPEHANDLE fd) + : TPipedBase(fd) +{ +} + TPipedOutput::~TPipedOutput() = default; - -void TPipedOutput::DoWrite(const void* buf, size_t len) { - if (!Handle_.IsOpen() || static_cast<ssize_t>(len) != Handle_.Write(buf, len)) { - ythrow TSystemError() << "pipe writing failed"; - } -} + +void TPipedOutput::DoWrite(const void* buf, size_t len) { + if (!Handle_.IsOpen() || static_cast<ssize_t>(len) != Handle_.Write(buf, len)) { + ythrow TSystemError() << "pipe writing failed"; + } +} diff --git a/util/stream/pipe.h b/util/stream/pipe.h index 18525b9517..7ef5766e6e 100644 --- a/util/stream/pipe.h +++ b/util/stream/pipe.h @@ -76,15 +76,15 @@ private: void DoWrite(const void* buf, size_t len) override; }; -class TPipedBase { +class TPipedBase { protected: TPipedBase(PIPEHANDLE fd); virtual ~TPipedBase(); protected: TPipeHandle Handle_; -}; - +}; + /** * Input stream that binds to a standard output stream of an existing process. */ @@ -92,11 +92,11 @@ class TPipedInput: public TPipedBase, public IInputStream { public: TPipedInput(PIPEHANDLE fd); ~TPipedInput() override; - + private: size_t DoRead(void* buf, size_t len) override; -}; - +}; + /** * Output stream that binds to a standard input stream of an existing process. */ @@ -104,9 +104,9 @@ class TPipedOutput: public TPipedBase, public IOutputStream { public: TPipedOutput(PIPEHANDLE fd); ~TPipedOutput() override; - + private: void DoWrite(const void* buf, size_t len) override; -}; - +}; + /** @} */ |