diff options
author | Ivan Korostelev <ivan.korostelev@gmail.com> | 2022-02-10 16:46:41 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:41 +0300 |
commit | b5e813096385b2d9e16b572711fec5bf2eb5058d (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /util | |
parent | f3a52f9d3e18d1159abbc85fa65eeda69d971657 (diff) | |
download | ydb-b5e813096385b2d9e16b572711fec5bf2eb5058d.tar.gz |
Restoring authorship annotation for Ivan Korostelev <ivan.korostelev@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r-- | util/charset/wide.cpp | 8 | ||||
-rw-r--r-- | util/draft/holder_vector.h | 2 | ||||
-rw-r--r-- | util/generic/maybe.h | 8 | ||||
-rw-r--r-- | util/generic/maybe_ut.cpp | 22 | ||||
-rw-r--r-- | util/network/socket.h | 10 | ||||
-rw-r--r-- | util/string/cast.cpp | 4 | ||||
-rw-r--r-- | util/string/strip.h | 62 | ||||
-rw-r--r-- | util/string/strip_ut.cpp | 12 | ||||
-rw-r--r-- | util/string/util.h | 2 | ||||
-rw-r--r-- | util/thread/pool.cpp | 4 | ||||
-rw-r--r-- | util/thread/pool_ut.cpp | 4 | ||||
-rw-r--r-- | util/ysaveload.h | 14 |
12 files changed, 76 insertions, 76 deletions
diff --git a/util/charset/wide.cpp b/util/charset/wide.cpp index 25ba822ce7..a287438ddd 100644 --- a/util/charset/wide.cpp +++ b/util/charset/wide.cpp @@ -1,8 +1,8 @@ #include "wide.h" #include <util/generic/mem_copy.h> -#include <util/string/strip.h> - +#include <util/string/strip.h> + namespace { //! the constants are not zero-terminated const wchar16 LT[] = {'&', 'l', 't', ';'}; @@ -32,11 +32,11 @@ namespace { } void Collapse(TUtf16String& w) { - CollapseImpl(w, w, 0, IsWhitespace); + CollapseImpl(w, w, 0, IsWhitespace); } size_t Collapse(wchar16* s, size_t n) { - return CollapseImpl(s, n, IsWhitespace); + return CollapseImpl(s, n, IsWhitespace); } TWtringBuf StripLeft(const TWtringBuf text) noexcept { diff --git a/util/draft/holder_vector.h b/util/draft/holder_vector.h index 651a171a50..1c62055bd9 100644 --- a/util/draft/holder_vector.h +++ b/util/draft/holder_vector.h @@ -73,7 +73,7 @@ public: void Resize(size_t newSize) { for (size_t i = newSize; i < size(); ++i) { - D::Destroy((*this)[i]); + D::Destroy((*this)[i]); } TBase::resize(newSize); } diff --git a/util/generic/maybe.h b/util/generic/maybe.h index 1e21f07e9c..34d21aebcd 100644 --- a/util/generic/maybe.h +++ b/util/generic/maybe.h @@ -447,7 +447,7 @@ private: this->Defined_ = true; } }; - + template <class T> using TMaybeFail = TMaybe<T, NMaybe::TPolicyUndefinedFail>; @@ -492,12 +492,12 @@ constexpr bool operator==(const ::TMaybe<T, TPolicy>& left, const ::TMaybe<T, TP !static_cast<bool>(left) ? true : *left == *right); -} - +} + template <class T, class TPolicy> constexpr bool operator!=(const TMaybe<T, TPolicy>& left, const TMaybe<T, TPolicy>& right) { return !(left == right); -} +} template <class T, class TPolicy> constexpr bool operator<(const TMaybe<T, TPolicy>& left, const TMaybe<T, TPolicy>& right) { diff --git a/util/generic/maybe_ut.cpp b/util/generic/maybe_ut.cpp index 597e725819..2c1a425c5e 100644 --- a/util/generic/maybe_ut.cpp +++ b/util/generic/maybe_ut.cpp @@ -103,7 +103,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(!m5.Defined()); UNIT_ASSERT(m5.Empty()); UNIT_ASSERT(m5 == TMaybe<int>()); - UNIT_ASSERT(m5 == Nothing()); + UNIT_ASSERT(m5 == Nothing()); UNIT_ASSERT(m5 != TMaybe<int>(4)); m5 = 4; @@ -115,7 +115,7 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(m5 == TMaybe<int>(4)); UNIT_ASSERT(m5 != TMaybe<int>(3)); UNIT_ASSERT(m5 != TMaybe<int>()); - UNIT_ASSERT(m5 != Nothing()); + UNIT_ASSERT(m5 != Nothing()); m5 = TMaybe<int>(5); UNIT_ASSERT(m5.Defined()); @@ -126,16 +126,16 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { m5 = TMaybe<int>(); UNIT_ASSERT(m5.Empty()); UNIT_ASSERT(m5 == TMaybe<int>()); - UNIT_ASSERT(m5 == Nothing()); + UNIT_ASSERT(m5 == Nothing()); + UNIT_ASSERT(m5 != TMaybe<int>(5)); + + m5 = 4; + m5 = Nothing(); + + UNIT_ASSERT(m5.Empty()); + UNIT_ASSERT(m5 == TMaybe<int>()); + UNIT_ASSERT(m5 == Nothing()); UNIT_ASSERT(m5 != TMaybe<int>(5)); - - m5 = 4; - m5 = Nothing(); - - UNIT_ASSERT(m5.Empty()); - UNIT_ASSERT(m5 == TMaybe<int>()); - UNIT_ASSERT(m5 == Nothing()); - UNIT_ASSERT(m5 != TMaybe<int>(5)); m5 = {}; UNIT_ASSERT(m5.Empty()); diff --git a/util/network/socket.h b/util/network/socket.h index b0a2d1aeaf..40c8648b40 100644 --- a/util/network/socket.h +++ b/util/network/socket.h @@ -234,8 +234,8 @@ private: TSimpleIntrusivePtr<TImpl> Impl_; }; -class TSocket; - +class TSocket; + class TSocketHolder: public TMoveOnly { public: inline TSocketHolder() @@ -290,9 +290,9 @@ public: private: SOCKET Fd_; - - // do not allow construction of TSocketHolder from TSocket - TSocketHolder(const TSocket& fd); + + // do not allow construction of TSocketHolder from TSocket + TSocketHolder(const TSocket& fd); }; class TSocket { diff --git a/util/string/cast.cpp b/util/string/cast.cpp index eda6fd4ee8..aa1e65a8e9 100644 --- a/util/string/cast.cpp +++ b/util/string/cast.cpp @@ -468,8 +468,8 @@ DEF_INT_SPEC_I(wchar32, ui64) // wchar32 is always unsigned return FormatFlt<type>(t, buf, len); \ } -DEF_FLT_SPEC(long double) - +DEF_FLT_SPEC(long double) + #undef DEF_FLT_SPEC template <> diff --git a/util/string/strip.h b/util/string/strip.h index f462e8a17f..d5ef6da96d 100644 --- a/util/string/strip.h +++ b/util/string/strip.h @@ -196,40 +196,40 @@ inline TString Strip(const TString& s) { return ret; } -template <class TChar, class TWhitespaceFunc> -size_t CollapseImpl(TChar* s, size_t n, const TWhitespaceFunc& isWhitespace) { - size_t newLen = 0; - for (size_t i = 0; i < n; ++i, ++newLen) { - size_t nextNonSpace = i; - while (nextNonSpace < n && isWhitespace(s[nextNonSpace])) { - ++nextNonSpace; - } - size_t numSpaces = nextNonSpace - i; - if (numSpaces > 1 || (numSpaces == 1 && s[i] != ' ')) { - s[newLen] = ' '; - i = nextNonSpace - 1; - } else { - s[newLen] = s[i]; - } - } - return newLen; -} - +template <class TChar, class TWhitespaceFunc> +size_t CollapseImpl(TChar* s, size_t n, const TWhitespaceFunc& isWhitespace) { + size_t newLen = 0; + for (size_t i = 0; i < n; ++i, ++newLen) { + size_t nextNonSpace = i; + while (nextNonSpace < n && isWhitespace(s[nextNonSpace])) { + ++nextNonSpace; + } + size_t numSpaces = nextNonSpace - i; + if (numSpaces > 1 || (numSpaces == 1 && s[i] != ' ')) { + s[newLen] = ' '; + i = nextNonSpace - 1; + } else { + s[newLen] = s[i]; + } + } + return newLen; +} + template <class TStringType, class TWhitespaceFunc> bool CollapseImpl(const TStringType& from, TStringType& to, size_t maxLen, const TWhitespaceFunc& isWhitespace) { - to = from; + to = from; maxLen = maxLen ? Min(maxLen, to.size()) : to.size(); - for (size_t i = 0; i < maxLen; ++i) { - if (isWhitespace(to[i]) && (to[i] != ' ' || isWhitespace(to[i + 1]))) { - size_t tailSize = maxLen - i; - size_t newTailSize = CollapseImpl(to.begin() + i, tailSize, isWhitespace); - to.remove(i + newTailSize, tailSize - newTailSize); - return true; - } - } - return false; -} - + for (size_t i = 0; i < maxLen; ++i) { + if (isWhitespace(to[i]) && (to[i] != ' ' || isWhitespace(to[i + 1]))) { + size_t tailSize = maxLen - i; + size_t newTailSize = CollapseImpl(to.begin() + i, tailSize, isWhitespace); + to.remove(i + newTailSize, tailSize - newTailSize); + return true; + } + } + return false; +} + bool Collapse(const TString& from, TString& to, size_t maxLen = 0); /// Replaces several consequtive space symbols with one (processing is limited to maxLen bytes) diff --git a/util/string/strip_ut.cpp b/util/string/strip_ut.cpp index 58f0a9e3df..d1029d1498 100644 --- a/util/string/strip_ut.cpp +++ b/util/string/strip_ut.cpp @@ -110,17 +110,17 @@ Y_UNIT_TEST_SUITE(TStripStringTest) { Y_UNIT_TEST(TestCollapse) { TString s; Collapse(TString(" 123 456 "), s); - UNIT_ASSERT(s == " 123 456 "); + UNIT_ASSERT(s == " 123 456 "); Collapse(TString(" 123 456 "), s, 10); - UNIT_ASSERT(s == " 123 456 "); - + UNIT_ASSERT(s == " 123 456 "); + s = TString(" a b c "); TString s2 = s; CollapseInPlace(s2); - - UNIT_ASSERT(s == s2); + + UNIT_ASSERT(s == s2); #ifndef TSTRING_IS_STD_STRING - UNIT_ASSERT(s.c_str() == s2.c_str()); // Collapse() does not change the string at all + UNIT_ASSERT(s.c_str() == s2.c_str()); // Collapse() does not change the string at all #endif } diff --git a/util/string/util.h b/util/string/util.h index b806bbf5c7..0d77a5042b 100644 --- a/util/string/util.h +++ b/util/string/util.h @@ -3,7 +3,7 @@ //THIS FILE A COMPAT STUB HEADER #include <cstring> -#include <cstdarg> +#include <cstdarg> #include <algorithm> #include <util/system/defaults.h> diff --git a/util/thread/pool.cpp b/util/thread/pool.cpp index 911ed3a276..05fad02e9b 100644 --- a/util/thread/pool.cpp +++ b/util/thread/pool.cpp @@ -175,7 +175,7 @@ private: inline void Stop() { AtomicSet(ShouldTerminate, 1); - + with_lock (QueueMutex) { QueuePopCond.BroadCast(); } @@ -224,7 +224,7 @@ private: job = Queue.Pop(); } - + QueuePopCond.Signal(); if (Catching) { diff --git a/util/thread/pool_ut.cpp b/util/thread/pool_ut.cpp index 4c73d23947..893770d0c4 100644 --- a/util/thread/pool_ut.cpp +++ b/util/thread/pool_ut.cpp @@ -72,13 +72,13 @@ struct TThreadPoolTest { UNIT_ASSERT_EQUAL(0, R); } }; - + class TFailAddQueue: public IThreadPool { public: bool Add(IObjectInQueue* /*obj*/) override Y_WARN_UNUSED_RESULT { return false; } - + void Start(size_t, size_t) override { } diff --git a/util/ysaveload.h b/util/ysaveload.h index 7cf1583075..02efb4049b 100644 --- a/util/ysaveload.h +++ b/util/ysaveload.h @@ -382,22 +382,22 @@ template <class T, class A> class TSerializer<std::deque<T, A>>: public TVectorSerializer<std::deque<T, A>> { }; -template <class TArray> +template <class TArray> class TStdArraySerializer { public: static inline void Save(IOutputStream* rh, const TArray& a) { ::SaveArray(rh, a.data(), a.size()); } - + static inline void Load(IInputStream* rh, TArray& a) { ::LoadArray(rh, a.data(), a.size()); } -}; - -template <class T, size_t N> +}; + +template <class T, size_t N> class TSerializer<std::array<T, N>>: public TStdArraySerializer<std::array<T, N>> { -}; - +}; + template <class A, class B> class TSerializer<std::pair<A, B>> { using TPair = std::pair<A, B>; |