diff options
author | swarmer <swarmer@yandex-team.ru> | 2022-02-10 16:46:31 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:31 +0300 |
commit | 11a24635da4c4f39428b182c49a7bc35e47c9534 (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library | |
parent | 317da38588b7898a99fd9168571408123350012b (diff) | |
download | ydb-11a24635da4c4f39428b182c49a7bc35e47c9534.tar.gz |
Restoring authorship annotation for <swarmer@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library')
32 files changed, 274 insertions, 274 deletions
diff --git a/library/cpp/blockcodecs/core/codecs.cpp b/library/cpp/blockcodecs/core/codecs.cpp index 3000c1f333..21506e812b 100644 --- a/library/cpp/blockcodecs/core/codecs.cpp +++ b/library/cpp/blockcodecs/core/codecs.cpp @@ -11,7 +11,7 @@ #include <util/system/unaligned_mem.h> #include <util/generic/hash.h> #include <util/generic/cast.h> -#include <util/generic/deque.h> +#include <util/generic/deque.h> #include <util/generic/buffer.h> #include <util/generic/array_ref.h> #include <util/generic/singleton.h> @@ -59,7 +59,7 @@ namespace { Registry[Tmp.back()] = Registry[to]; } - TDeque<TString> Tmp; + TDeque<TString> Tmp; TNullCodec Null; TVector<TCodecPtr> Codecs; typedef THashMap<TStringBuf, ICodec*> TRegistry; diff --git a/library/cpp/containers/bitseq/traits.h b/library/cpp/containers/bitseq/traits.h index a852ea8d40..2330b1b4f2 100644 --- a/library/cpp/containers/bitseq/traits.h +++ b/library/cpp/containers/bitseq/traits.h @@ -6,9 +6,9 @@ template <typename TWord> struct TBitSeqTraits { - static constexpr ui8 NumBits = CHAR_BIT * sizeof(TWord); - static constexpr TWord ModMask = static_cast<TWord>(NumBits - 1); - static constexpr TWord DivShift = MostSignificantBitCT(NumBits); + static constexpr ui8 NumBits = CHAR_BIT * sizeof(TWord); + static constexpr TWord ModMask = static_cast<TWord>(NumBits - 1); + static constexpr TWord DivShift = MostSignificantBitCT(NumBits); static inline TWord ElemMask(ui8 count) { // NOTE: Shifting by the type's length is UB, so we need this workaround. diff --git a/library/cpp/containers/stack_vector/stack_vec.h b/library/cpp/containers/stack_vector/stack_vec.h index 42e46e23f2..fcc5d9a2a5 100644 --- a/library/cpp/containers/stack_vector/stack_vec.h +++ b/library/cpp/containers/stack_vector/stack_vec.h @@ -76,18 +76,18 @@ namespace NPrivate { Y_VERIFY(IsStorageUsed); IsStorageUsed = false; } else { - FallbackAllocator().deallocate(p, n); + FallbackAllocator().deallocate(p, n); } } private: std::aligned_storage_t<sizeof(T), alignof(T)> StackBasedStorage[CountOnStack]; bool IsStorageUsed = false; - - private: - Alloc& FallbackAllocator() noexcept { - return static_cast<Alloc&>(*this); - } + + private: + Alloc& FallbackAllocator() noexcept { + return static_cast<Alloc&>(*this); + } }; } diff --git a/library/cpp/containers/stack_vector/stack_vec_ut.cpp b/library/cpp/containers/stack_vector/stack_vec_ut.cpp index bdb66f8c4f..19f9677781 100644 --- a/library/cpp/containers/stack_vector/stack_vec_ut.cpp +++ b/library/cpp/containers/stack_vector/stack_vec_ut.cpp @@ -9,16 +9,16 @@ namespace { static_assert(std::is_copy_constructible_v<TNotCopyAssignable>); static_assert(!std::is_copy_assignable_v<TNotCopyAssignable>); - - template <class T, size_t JunkPayloadSize> - struct TThickAlloc: public std::allocator<T> { - template <class U> - struct rebind { - using other = TThickAlloc<U, JunkPayloadSize>; - }; - - char Junk[JunkPayloadSize]{sizeof(T)}; - }; + + template <class T, size_t JunkPayloadSize> + struct TThickAlloc: public std::allocator<T> { + template <class U> + struct rebind { + using other = TThickAlloc<U, JunkPayloadSize>; + }; + + char Junk[JunkPayloadSize]{sizeof(T)}; + }; template <class T> struct TStatefulAlloc: public std::allocator<T> { @@ -126,12 +126,12 @@ Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { } // Just verify that the program did not crash. } - - Y_UNIT_TEST(TestCustomAllocSize) { - constexpr size_t n = 16384; - using TVec = TStackVec<size_t, 1, true, TThickAlloc<size_t, n>>; - UNIT_ASSERT_LT(sizeof(TVec), 1.5 * n); - } + + Y_UNIT_TEST(TestCustomAllocSize) { + constexpr size_t n = 16384; + using TVec = TStackVec<size_t, 1, true, TThickAlloc<size_t, n>>; + UNIT_ASSERT_LT(sizeof(TVec), 1.5 * n); + } Y_UNIT_TEST(TestStatefulAlloc) { size_t count = 0; diff --git a/library/cpp/diff/diff.h b/library/cpp/diff/diff.h index 1648b86643..94fb00cd0b 100644 --- a/library/cpp/diff/diff.h +++ b/library/cpp/diff/diff.h @@ -2,7 +2,7 @@ #include <library/cpp/lcs/lcs_via_lis.h> -#include <util/generic/algorithm.h> +#include <util/generic/algorithm.h> #include <util/generic/array_ref.h> #include <util/generic/strbuf.h> #include <util/generic/vector.h> @@ -63,7 +63,7 @@ namespace NDiff { // Save the beginning of common part in s2 c2 = s2.begin() + ctx.ResultBuffer[i]; // Find the beginning of common part in s1 - c1 = Find(e1, s1.end(), *c2); + c1 = Find(e1, s1.end(), *c2); // Follow common substring for (e1 = c1, e2 = c2; i < n && *e1 == *e2; ++e1, ++e2) { ++i; diff --git a/library/cpp/getopt/small/last_getopt.h b/library/cpp/getopt/small/last_getopt.h index 5314861064..07687bc914 100644 --- a/library/cpp/getopt/small/last_getopt.h +++ b/library/cpp/getopt/small/last_getopt.h @@ -9,7 +9,7 @@ /// see some documentation in /// https://wiki.yandex-team.ru/development/poisk/arcadia/util/lastgetopt/ -/// https://wiki.yandex-team.ru/development/poisk/arcadia/library/getopt/ +/// https://wiki.yandex-team.ru/development/poisk/arcadia/library/getopt/ /// see examples in library/cpp/getopt/last_getopt_demo //TODO: in most cases this include is unnecessary, but needed THandlerFunctor1<TpFunc, TpArg>::HandleOpt diff --git a/library/cpp/getopt/small/last_getopt_opt.h b/library/cpp/getopt/small/last_getopt_opt.h index f4d7c2cbad..a8dd5adca9 100644 --- a/library/cpp/getopt/small/last_getopt_opt.h +++ b/library/cpp/getopt/small/last_getopt_opt.h @@ -604,12 +604,12 @@ namespace NLastGetopt { return StoreResultT<T>(target); } - // Uses TMaybe<T> to store FromString<T>(arg) - template <typename T> - TOpt& StoreResult(TMaybe<T>* target) { - return StoreResultT<T>(target); - } - + // Uses TMaybe<T> to store FromString<T>(arg) + template <typename T> + TOpt& StoreResult(TMaybe<T>* target) { + return StoreResultT<T>(target); + } + template <typename TpVal, typename T, typename TpDef> TOpt& StoreResultT(T* target, const TpDef& def) { return Handler1T<TpVal>(def, NPrivate::TStoreResultFunctor<T, TpVal>(target)); diff --git a/library/cpp/getopt/ut/last_getopt_ut.cpp b/library/cpp/getopt/ut/last_getopt_ut.cpp index b17fc90cd0..c99a1d053d 100644 --- a/library/cpp/getopt/ut/last_getopt_ut.cpp +++ b/library/cpp/getopt/ut/last_getopt_ut.cpp @@ -419,21 +419,21 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { TOptsNoDefault opts; TString data; int number; - TMaybe<TString> optionalString0, optionalString1; - TMaybe<int> optionalNumber0, optionalNumber1; + TMaybe<TString> optionalString0, optionalString1; + TMaybe<int> optionalNumber0, optionalNumber1; opts.AddLongOption('d', "data").StoreResult(&data); opts.AddLongOption('n', "number").StoreResult(&number); - opts.AddLongOption("optional-string-0").StoreResult(&optionalString0); - opts.AddLongOption("optional-number-0").StoreResult(&optionalNumber0); - opts.AddLongOption("optional-string-1").StoreResult(&optionalString1); - opts.AddLongOption("optional-number-1").StoreResult(&optionalNumber1); - TOptsParseResultTestWrapper r(&opts, V({"cmd", "--data=jjhh", "-n", "11", "--optional-number-1=8", "--optional-string-1=os1"})); + opts.AddLongOption("optional-string-0").StoreResult(&optionalString0); + opts.AddLongOption("optional-number-0").StoreResult(&optionalNumber0); + opts.AddLongOption("optional-string-1").StoreResult(&optionalString1); + opts.AddLongOption("optional-number-1").StoreResult(&optionalNumber1); + TOptsParseResultTestWrapper r(&opts, V({"cmd", "--data=jjhh", "-n", "11", "--optional-number-1=8", "--optional-string-1=os1"})); UNIT_ASSERT_VALUES_EQUAL("jjhh", data); UNIT_ASSERT_VALUES_EQUAL(11, number); - UNIT_ASSERT(!optionalString0.Defined()); - UNIT_ASSERT(!optionalNumber0.Defined()); - UNIT_ASSERT_VALUES_EQUAL(*optionalString1, "os1"); - UNIT_ASSERT_VALUES_EQUAL(*optionalNumber1, 8); + UNIT_ASSERT(!optionalString0.Defined()); + UNIT_ASSERT(!optionalNumber0.Defined()); + UNIT_ASSERT_VALUES_EQUAL(*optionalString1, "os1"); + UNIT_ASSERT_VALUES_EQUAL(*optionalNumber1, 8); } Y_UNIT_TEST(TestStoreValue) { diff --git a/library/cpp/iterator/ya.make b/library/cpp/iterator/ya.make index bc412ee74a..1ba1ffb411 100644 --- a/library/cpp/iterator/ya.make +++ b/library/cpp/iterator/ya.make @@ -15,5 +15,5 @@ SRCS( ) END() - -RECURSE_FOR_TESTS(ut) + +RECURSE_FOR_TESTS(ut) diff --git a/library/cpp/json/domscheme_traits.h b/library/cpp/json/domscheme_traits.h index f5961f2592..a5a99cd8cf 100644 --- a/library/cpp/json/domscheme_traits.h +++ b/library/cpp/json/domscheme_traits.h @@ -100,7 +100,7 @@ struct TJsonTraits { return &(*v)[key]; } - static inline size_t DictSize(TConstValueRef v) { + static inline size_t DictSize(TConstValueRef v) { return v->GetMap().size(); } diff --git a/library/cpp/json/writer/json.cpp b/library/cpp/json/writer/json.cpp index afc98b8a60..02370c2d79 100644 --- a/library/cpp/json/writer/json.cpp +++ b/library/cpp/json/writer/json.cpp @@ -89,24 +89,24 @@ namespace NJsonWriter { const int indentation = IndentSpaces * (Stack.size() - 1); if (!indentation && !closing) return; - - PrintWhitespaces(Max(0, indentation), true); - } - - void TBuf::PrintWhitespaces(size_t count, bool prependWithNewLine) { - static constexpr TStringBuf whitespacesTemplate = "\n "; - static_assert(whitespacesTemplate[0] == '\n'); - static_assert(whitespacesTemplate[1] == ' '); - - count += (prependWithNewLine); - do { - const TStringBuf buffer = whitespacesTemplate.SubString(prependWithNewLine ? 0 : 1, count); - count -= buffer.size(); - UnsafeWriteRawBytes(buffer); - prependWithNewLine = false; // skip '\n' in subsequent writes - } while (count > 0); - } - + + PrintWhitespaces(Max(0, indentation), true); + } + + void TBuf::PrintWhitespaces(size_t count, bool prependWithNewLine) { + static constexpr TStringBuf whitespacesTemplate = "\n "; + static_assert(whitespacesTemplate[0] == '\n'); + static_assert(whitespacesTemplate[1] == ' '); + + count += (prependWithNewLine); + do { + const TStringBuf buffer = whitespacesTemplate.SubString(prependWithNewLine ? 0 : 1, count); + count -= buffer.size(); + UnsafeWriteRawBytes(buffer); + prependWithNewLine = false; // skip '\n' in subsequent writes + } while (count > 0); + } + inline void TBuf::WriteComma() { if (NeedComma) { RawWriteChar(','); diff --git a/library/cpp/json/writer/json.h b/library/cpp/json/writer/json.h index 3849dc4ba4..0aae2531b9 100644 --- a/library/cpp/json/writer/json.h +++ b/library/cpp/json/writer/json.h @@ -133,7 +133,7 @@ namespace NJsonWriter { void WriteBareString(const TStringBuf s, EHtmlEscapeMode hem); void WriteComma(); void PrintIndentation(bool closing); - void PrintWhitespaces(size_t count, bool prependWithNewLine); + void PrintWhitespaces(size_t count, bool prependWithNewLine); void WriteHexEscape(unsigned char c); void StackPush(EJsonEntity e); diff --git a/library/cpp/lwtrace/all.h b/library/cpp/lwtrace/all.h index 27163051e0..d7aa57c49d 100644 --- a/library/cpp/lwtrace/all.h +++ b/library/cpp/lwtrace/all.h @@ -7,7 +7,7 @@ #include "start.h" // -// Full documentation: https://wiki.yandex-team.ru/development/poisk/arcadia/library/lwtrace/ +// Full documentation: https://wiki.yandex-team.ru/development/poisk/arcadia/library/lwtrace/ // // Short usage instruction: // diff --git a/library/cpp/monlib/metrics/ut/ya.make b/library/cpp/monlib/metrics/ut/ya.make index 26667a8eed..aec9974fbd 100644 --- a/library/cpp/monlib/metrics/ut/ya.make +++ b/library/cpp/monlib/metrics/ut/ya.make @@ -26,7 +26,7 @@ PEERDIR( library/cpp/resource library/cpp/monlib/encode/protobuf library/cpp/monlib/encode/json - library/cpp/threading/future + library/cpp/threading/future ) END() diff --git a/library/cpp/protobuf/util/pb_io.cpp b/library/cpp/protobuf/util/pb_io.cpp index 58b4960f9c..6270ee0624 100644 --- a/library/cpp/protobuf/util/pb_io.cpp +++ b/library/cpp/protobuf/util/pb_io.cpp @@ -69,16 +69,16 @@ namespace NProtoBuf { return result; } - bool MergePartialFromString(NProtoBuf::Message& m, const TStringBuf serializedProtoMessage) { - google::protobuf::io::CodedInputStream input(reinterpret_cast<const ui8*>(serializedProtoMessage.data()), serializedProtoMessage.size()); - bool ok = m.MergePartialFromCodedStream(&input); - ok = ok && input.ConsumedEntireMessage(); - return ok; - } - - bool MergeFromString(NProtoBuf::Message& m, const TStringBuf serializedProtoMessage) { - return MergePartialFromString(m, serializedProtoMessage) && m.IsInitialized(); - } + bool MergePartialFromString(NProtoBuf::Message& m, const TStringBuf serializedProtoMessage) { + google::protobuf::io::CodedInputStream input(reinterpret_cast<const ui8*>(serializedProtoMessage.data()), serializedProtoMessage.size()); + bool ok = m.MergePartialFromCodedStream(&input); + ok = ok && input.ConsumedEntireMessage(); + return ok; + } + + bool MergeFromString(NProtoBuf::Message& m, const TStringBuf serializedProtoMessage) { + return MergePartialFromString(m, serializedProtoMessage) && m.IsInitialized(); + } } int operator&(NProtoBuf::Message& m, IBinSaver& f) { diff --git a/library/cpp/protobuf/util/pb_io.h b/library/cpp/protobuf/util/pb_io.h index aad964555b..493c84cb5f 100644 --- a/library/cpp/protobuf/util/pb_io.h +++ b/library/cpp/protobuf/util/pb_io.h @@ -37,9 +37,9 @@ namespace NProtoBuf { bool TrySerializeToBase64String(const Message& m, TString& dataBase64); const TString ShortUtf8DebugString(const Message& message); - - bool MergePartialFromString(NProtoBuf::Message& m, const TStringBuf serializedProtoMessage); - bool MergeFromString(NProtoBuf::Message& m, const TStringBuf serializedProtoMessage); + + bool MergePartialFromString(NProtoBuf::Message& m, const TStringBuf serializedProtoMessage); + bool MergeFromString(NProtoBuf::Message& m, const TStringBuf serializedProtoMessage); } int operator&(NProtoBuf::Message& m, IBinSaver& f); diff --git a/library/cpp/protobuf/util/pb_io_ut.cpp b/library/cpp/protobuf/util/pb_io_ut.cpp index 2b93d64b5d..875d6dc602 100644 --- a/library/cpp/protobuf/util/pb_io_ut.cpp +++ b/library/cpp/protobuf/util/pb_io_ut.cpp @@ -383,36 +383,36 @@ Y_UNIT_TEST_SUITE(TTestProtoBufIO) { UNIT_ASSERT(NProtoBuf::IsEqual(message, GetCorrectMessage())); } } - - Y_UNIT_TEST(TestMergeFromString) { - NProtobufUtilUt::TMergeTest message; - NProtobufUtilUt::TMergeTest messageFirstHalf; - NProtobufUtilUt::TMergeTest messageSecondHalf; - - for (ui32 v = ~0; v != 0; v >>= 1) { - message.AddMergeInt(v); - (v > 0xffff ? messageFirstHalf : messageSecondHalf).AddMergeInt(v); - } - - const TString full = message.SerializeAsString(); - - { - NProtobufUtilUt::TMergeTest m1; - UNIT_ASSERT(NProtoBuf::MergeFromString(m1, full)); - UNIT_ASSERT(NProtoBuf::IsEqual(message, m1)); - } - { - NProtobufUtilUt::TMergeTest m2; - TStringBuf s0 = TStringBuf(full).SubStr(0, 3); - TStringBuf s1 = TStringBuf(full).SubStr(3); - // объединение результатов двух MergePartialFromString не эквивалентно вызову MergePartialFromString от объединения строк - UNIT_ASSERT(!(NProtoBuf::MergePartialFromString(m2, s0) && NProtoBuf::MergePartialFromString(m2, s1))); - } - { - NProtobufUtilUt::TMergeTest m3; - UNIT_ASSERT(NProtoBuf::MergePartialFromString(m3, messageFirstHalf.SerializeAsString())); - UNIT_ASSERT(NProtoBuf::MergeFromString(m3, messageSecondHalf.SerializeAsString())); - UNIT_ASSERT(NProtoBuf::IsEqual(message, m3)); - } - } + + Y_UNIT_TEST(TestMergeFromString) { + NProtobufUtilUt::TMergeTest message; + NProtobufUtilUt::TMergeTest messageFirstHalf; + NProtobufUtilUt::TMergeTest messageSecondHalf; + + for (ui32 v = ~0; v != 0; v >>= 1) { + message.AddMergeInt(v); + (v > 0xffff ? messageFirstHalf : messageSecondHalf).AddMergeInt(v); + } + + const TString full = message.SerializeAsString(); + + { + NProtobufUtilUt::TMergeTest m1; + UNIT_ASSERT(NProtoBuf::MergeFromString(m1, full)); + UNIT_ASSERT(NProtoBuf::IsEqual(message, m1)); + } + { + NProtobufUtilUt::TMergeTest m2; + TStringBuf s0 = TStringBuf(full).SubStr(0, 3); + TStringBuf s1 = TStringBuf(full).SubStr(3); + // объединение результатов двух MergePartialFromString не эквивалентно вызову MergePartialFromString от объединения строк + UNIT_ASSERT(!(NProtoBuf::MergePartialFromString(m2, s0) && NProtoBuf::MergePartialFromString(m2, s1))); + } + { + NProtobufUtilUt::TMergeTest m3; + UNIT_ASSERT(NProtoBuf::MergePartialFromString(m3, messageFirstHalf.SerializeAsString())); + UNIT_ASSERT(NProtoBuf::MergeFromString(m3, messageSecondHalf.SerializeAsString())); + UNIT_ASSERT(NProtoBuf::IsEqual(message, m3)); + } + } } diff --git a/library/cpp/regex/pcre/regexp_ut.cpp b/library/cpp/regex/pcre/regexp_ut.cpp index 900d9587d8..5184e801cc 100644 --- a/library/cpp/regex/pcre/regexp_ut.cpp +++ b/library/cpp/regex/pcre/regexp_ut.cpp @@ -50,7 +50,7 @@ private: UNIT_TEST_SUITE(TRegexpTest); UNIT_TEST(TestRe) UNIT_TEST(TestSubst) - UNIT_TEST(TestOffEndOfBuffer); + UNIT_TEST(TestOffEndOfBuffer); UNIT_TEST_SUITE_END(); inline void TestRe() { @@ -91,13 +91,13 @@ private: UNIT_ASSERT_VALUES_EQUAL(copyResult, newResult); } } - - void TestOffEndOfBuffer() { - const TString needle{".*[^./]gov[.].*"}; - TRegExMatch re{needle, REG_UTF8}; - const TString haystack{"fakty.ictv.ua"}; - UNIT_ASSERT_VALUES_EQUAL(re.Match(haystack.c_str()), false); - } + + void TestOffEndOfBuffer() { + const TString needle{".*[^./]gov[.].*"}; + TRegExMatch re{needle, REG_UTF8}; + const TString haystack{"fakty.ictv.ua"}; + UNIT_ASSERT_VALUES_EQUAL(re.Match(haystack.c_str()), false); + } }; UNIT_TEST_SUITE_REGISTRATION(TRegexpTest); diff --git a/library/cpp/regex/pire/ut/regexp_ut.cpp b/library/cpp/regex/pire/ut/regexp_ut.cpp index b19c9a01f8..e7206de9ad 100644 --- a/library/cpp/regex/pire/ut/regexp_ut.cpp +++ b/library/cpp/regex/pire/ut/regexp_ut.cpp @@ -8,7 +8,7 @@ Y_UNIT_TEST_SUITE(TRegExp) { Y_UNIT_TEST(False) { UNIT_ASSERT(!TMatcher(TFsm::False()).Match("").Final()); - UNIT_ASSERT(!TMatcher(TFsm::False()).Match(TStringBuf{}).Final()); + UNIT_ASSERT(!TMatcher(TFsm::False()).Match(TStringBuf{}).Final()); } Y_UNIT_TEST(Surround) { diff --git a/library/cpp/resource/registry.cpp b/library/cpp/resource/registry.cpp index c032fd4c05..66001c4769 100644 --- a/library/cpp/resource/registry.cpp +++ b/library/cpp/resource/registry.cpp @@ -21,7 +21,7 @@ namespace { typedef std::pair<TStringBuf, TStringBuf> TDescriptor; struct TStore: public IStore, public THashMap<TStringBuf, TDescriptor*> { - void Store(const TStringBuf key, const TStringBuf data) override { + void Store(const TStringBuf key, const TStringBuf data) override { if (contains(key)) { const TStringBuf value = (*this)[key]->second; if (value != data) { @@ -49,7 +49,7 @@ namespace { Y_VERIFY(size() == Count(), "size mismatch"); } - bool FindExact(const TStringBuf key, TString* out) const override { + bool FindExact(const TStringBuf key, TString* out) const override { if (TDescriptor* const* res = FindPtr(key)) { // temporary // https://st.yandex-team.ru/DEVTOOLS-3985 @@ -68,7 +68,7 @@ namespace { return false; } - void FindMatch(const TStringBuf subkey, IMatch& cb) const override { + void FindMatch(const TStringBuf subkey, IMatch& cb) const override { for (const auto& it : *this) { if (it.first.StartsWith(subkey)) { // temporary @@ -100,11 +100,11 @@ namespace { }; } -TString NResource::Compress(const TStringBuf data) { +TString NResource::Compress(const TStringBuf data) { return GetCodec()->Encode(data); } -TString NResource::Decompress(const TStringBuf data) { +TString NResource::Decompress(const TStringBuf data) { return GetCodec()->Decode(data); } diff --git a/library/cpp/resource/registry.h b/library/cpp/resource/registry.h index 819966fa31..fe67702cbc 100644 --- a/library/cpp/resource/registry.h +++ b/library/cpp/resource/registry.h @@ -6,8 +6,8 @@ #include "resource.h" namespace NResource { - TString Compress(const TStringBuf data); - TString Decompress(const TStringBuf data); + TString Compress(const TStringBuf data); + TString Decompress(const TStringBuf data); class IMatch { public: @@ -16,9 +16,9 @@ namespace NResource { class IStore { public: - virtual void Store(const TStringBuf key, const TStringBuf data) = 0; - virtual bool FindExact(const TStringBuf key, TString* out) const = 0; - virtual void FindMatch(const TStringBuf subkey, IMatch& cb) const = 0; + virtual void Store(const TStringBuf key, const TStringBuf data) = 0; + virtual bool FindExact(const TStringBuf key, TString* out) const = 0; + virtual void FindMatch(const TStringBuf subkey, IMatch& cb) const = 0; virtual size_t Count() const noexcept = 0; virtual TStringBuf KeyByIndex(size_t idx) const = 0; virtual ~IStore() { @@ -28,7 +28,7 @@ namespace NResource { IStore* CommonStore(); struct TRegHelper { - inline TRegHelper(const TStringBuf key, const TStringBuf data) { + inline TRegHelper(const TStringBuf key, const TStringBuf data) { CommonStore()->Store(key, data); } }; diff --git a/library/cpp/resource/resource.cpp b/library/cpp/resource/resource.cpp index af686951b9..cc20f847a5 100644 --- a/library/cpp/resource/resource.cpp +++ b/library/cpp/resource/resource.cpp @@ -7,11 +7,11 @@ using namespace NResource; -bool NResource::FindExact(const TStringBuf key, TString* out) { +bool NResource::FindExact(const TStringBuf key, TString* out) { return CommonStore()->FindExact(key, out); } -void NResource::FindMatch(const TStringBuf subkey, TResources* out) { +void NResource::FindMatch(const TStringBuf subkey, TResources* out) { struct TMatch: public IMatch { inline TMatch(TResources* r) : R(r) @@ -30,7 +30,7 @@ void NResource::FindMatch(const TStringBuf subkey, TResources* out) { CommonStore()->FindMatch(subkey, m); } -TString NResource::Find(const TStringBuf key) { +TString NResource::Find(const TStringBuf key) { TString ret; if (FindExact(key, &ret)) { diff --git a/library/cpp/resource/resource.h b/library/cpp/resource/resource.h index 7da20bdba7..42dd0f1891 100644 --- a/library/cpp/resource/resource.h +++ b/library/cpp/resource/resource.h @@ -12,10 +12,10 @@ namespace NResource { typedef TVector<TResource> TResources; - TString Find(const TStringBuf key); - bool FindExact(const TStringBuf key, TString* out); + TString Find(const TStringBuf key); + bool FindExact(const TStringBuf key, TString* out); //perform full scan for now - void FindMatch(const TStringBuf subkey, TResources* out); + void FindMatch(const TStringBuf subkey, TResources* out); size_t Count() noexcept; TStringBuf KeyByIndex(size_t idx); TVector<TStringBuf> ListAllKeys(); diff --git a/library/cpp/testing/benchmark/bench.cpp b/library/cpp/testing/benchmark/bench.cpp index a2245f20db..08d8708005 100644 --- a/library/cpp/testing/benchmark/bench.cpp +++ b/library/cpp/testing/benchmark/bench.cpp @@ -43,7 +43,7 @@ namespace { TMaybe<double> CyclesPerIteration; TMaybe<double> SecondsPerIteration; double RunTime; - size_t TestId; // Sequential test id (zero-based) + size_t TestId; // Sequential test id (zero-based) }; struct ITestRunner: public TIntrusiveListItem<ITestRunner> { @@ -52,7 +52,7 @@ namespace { virtual TStringBuf Name() const noexcept = 0; virtual TResult Run(const TOptions& opts) = 0; - size_t SequentialId = 0; + size_t SequentialId = 0; }; struct TCpuBenchmark: public ITestRunner { @@ -387,39 +387,39 @@ namespace { TVector<TResult> Results_; }; - class TOrderedReporter: public IReporter { - public: - TOrderedReporter(THolder<IReporter> slave) - : Slave_(std::move(slave)) - { - } - - void Report(TResult&& result) override { - with_lock (ResultsLock_) { - OrderedResultQueue_.emplace(result.TestId, std::move(result)); - while (!OrderedResultQueue_.empty() && OrderedResultQueue_.begin()->first <= ExpectedTestId_) { - Slave_->Report(std::move(OrderedResultQueue_.begin()->second)); - OrderedResultQueue_.erase(OrderedResultQueue_.begin()); - ++ExpectedTestId_; - } - } - } - - void Finish() override { - for (auto& it : OrderedResultQueue_) { - Slave_->Report(std::move(it.second)); - } - OrderedResultQueue_.clear(); - Slave_->Finish(); - } - - private: - THolder<IReporter> Slave_; - size_t ExpectedTestId_ = 0; - TMap<size_t, TResult> OrderedResultQueue_; - TAdaptiveLock ResultsLock_; - }; - + class TOrderedReporter: public IReporter { + public: + TOrderedReporter(THolder<IReporter> slave) + : Slave_(std::move(slave)) + { + } + + void Report(TResult&& result) override { + with_lock (ResultsLock_) { + OrderedResultQueue_.emplace(result.TestId, std::move(result)); + while (!OrderedResultQueue_.empty() && OrderedResultQueue_.begin()->first <= ExpectedTestId_) { + Slave_->Report(std::move(OrderedResultQueue_.begin()->second)); + OrderedResultQueue_.erase(OrderedResultQueue_.begin()); + ++ExpectedTestId_; + } + } + } + + void Finish() override { + for (auto& it : OrderedResultQueue_) { + Slave_->Report(std::move(it.second)); + } + OrderedResultQueue_.clear(); + Slave_->Finish(); + } + + private: + THolder<IReporter> Slave_; + size_t ExpectedTestId_ = 0; + TMap<size_t, TResult> OrderedResultQueue_; + TAdaptiveLock ResultsLock_; + }; + THolder<IReporter> MakeReporter(const EOutFormat type) { switch (type) { case F_CONSOLE: @@ -437,16 +437,16 @@ namespace { return MakeHolder<TConsoleReporter>(); // make compiler happy } - + THolder<IReporter> MakeOrderedReporter(const EOutFormat type) { - return MakeHolder<TOrderedReporter>(MakeReporter(type)); - } - + return MakeHolder<TOrderedReporter>(MakeReporter(type)); + } + void EnumerateTests(TVector<ITestRunner*>& tests) { - for (size_t id : xrange(tests.size())) { - tests[id]->SequentialId = id; - } - } + for (size_t id : xrange(tests.size())) { + tests[id]->SequentialId = id; + } + } } template <> @@ -560,7 +560,7 @@ int NBench::Main(int argc, char** argv) { tests.push_back(&it); } } - EnumerateTests(tests); + EnumerateTests(tests); if (opts.ListTests) { for (const auto* const it : tests) { @@ -581,7 +581,7 @@ int NBench::Main(int argc, char** argv) { } const TOptions testOpts = {timeBudget / tests.size()}; - const auto reporter = MakeOrderedReporter(opts.OutFormat); + const auto reporter = MakeOrderedReporter(opts.OutFormat); std::function<void(ITestRunner**)> func = [&](ITestRunner** it) { auto&& res = (*it)->Run(testOpts); diff --git a/library/cpp/threading/future/core/future-inl.h b/library/cpp/threading/future/core/future-inl.h index 109b94bf92..5fd4296a93 100644 --- a/library/cpp/threading/future/core/future-inl.h +++ b/library/cpp/threading/future/core/future-inl.h @@ -961,12 +961,12 @@ namespace NThreading { inline TFuture<T> MakeFuture() { struct TCache { TFuture<T> Instance{new NImpl::TFutureState<T>(Default<T>())}; - - TCache() { - // Immediately advance state from ValueSet to ValueRead. - // This should prevent corrupting shared value with an ExtractValue() call. - Y_UNUSED(Instance.GetValue()); - } + + TCache() { + // Immediately advance state from ValueSet to ValueRead. + // This should prevent corrupting shared value with an ExtractValue() call. + Y_UNUSED(Instance.GetValue()); + } }; return Singleton<TCache>()->Instance; } diff --git a/library/cpp/threading/future/future_ut.cpp b/library/cpp/threading/future/future_ut.cpp index 9ddca66b37..05950a568d 100644 --- a/library/cpp/threading/future/future_ut.cpp +++ b/library/cpp/threading/future/future_ut.cpp @@ -260,11 +260,11 @@ namespace { } - Y_UNIT_TEST(ShouldWaitExceptionOrAll) { + Y_UNIT_TEST(ShouldWaitExceptionOrAll) { TPromise<void> promise1 = NewPromise(); TPromise<void> promise2 = NewPromise(); - TFuture<void> future = WaitExceptionOrAll(promise1, promise2); + TFuture<void> future = WaitExceptionOrAll(promise1, promise2); UNIT_ASSERT(!future.HasValue()); promise1.SetValue(); @@ -274,7 +274,7 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldWaitExceptionOrAllVector) { + Y_UNIT_TEST(ShouldWaitExceptionOrAllVector) { TPromise<void> promise1 = NewPromise(); TPromise<void> promise2 = NewPromise(); @@ -282,7 +282,7 @@ namespace { promises.push_back(promise1); promises.push_back(promise2); - TFuture<void> future = WaitExceptionOrAll(promises); + TFuture<void> future = WaitExceptionOrAll(promises); UNIT_ASSERT(!future.HasValue()); promise1.SetValue(); @@ -292,7 +292,7 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldWaitExceptionOrAllVectorWithValueType) { + Y_UNIT_TEST(ShouldWaitExceptionOrAllVectorWithValueType) { TPromise<int> promise1 = NewPromise<int>(); TPromise<int> promise2 = NewPromise<int>(); @@ -300,7 +300,7 @@ namespace { promises.push_back(promise1); promises.push_back(promise2); - TFuture<void> future = WaitExceptionOrAll(promises); + TFuture<void> future = WaitExceptionOrAll(promises); UNIT_ASSERT(!future.HasValue()); promise1.SetValue(0); @@ -310,7 +310,7 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldWaitExceptionOrAllList) { + Y_UNIT_TEST(ShouldWaitExceptionOrAllList) { TPromise<void> promise1 = NewPromise(); TPromise<void> promise2 = NewPromise(); @@ -318,7 +318,7 @@ namespace { promises.push_back(promise1); promises.push_back(promise2); - TFuture<void> future = WaitExceptionOrAll(promises); + TFuture<void> future = WaitExceptionOrAll(promises); UNIT_ASSERT(!future.HasValue()); promise1.SetValue(); @@ -328,10 +328,10 @@ namespace { UNIT_ASSERT(future.HasValue()); } - Y_UNIT_TEST(ShouldWaitExceptionOrAllVectorEmpty) { + Y_UNIT_TEST(ShouldWaitExceptionOrAllVectorEmpty) { TVector<TFuture<void>> promises; - TFuture<void> future = WaitExceptionOrAll(promises); + TFuture<void> future = WaitExceptionOrAll(promises); UNIT_ASSERT(future.HasValue()); } @@ -480,21 +480,21 @@ namespace { UNIT_CHECK_GENERATED_EXCEPTION(promise.ExtractValue(), TFutureException); } - Y_UNIT_TEST(ShouldNotExtractFromSharedDefault) { - UNIT_CHECK_GENERATED_EXCEPTION(MakeFuture<int>().ExtractValue(), TFutureException); - - struct TStorage { - TString String = TString(100, 'a'); - }; - try { - TString s = MakeFuture<TStorage>().ExtractValue().String; - Y_UNUSED(s); - } catch (TFutureException) { - // pass - } - UNIT_ASSERT_VALUES_EQUAL(MakeFuture<TStorage>().GetValue().String, TString(100, 'a')); - } - + Y_UNIT_TEST(ShouldNotExtractFromSharedDefault) { + UNIT_CHECK_GENERATED_EXCEPTION(MakeFuture<int>().ExtractValue(), TFutureException); + + struct TStorage { + TString String = TString(100, 'a'); + }; + try { + TString s = MakeFuture<TStorage>().ExtractValue().String; + Y_UNUSED(s); + } catch (TFutureException) { + // pass + } + UNIT_ASSERT_VALUES_EQUAL(MakeFuture<TStorage>().GetValue().String, TString(100, 'a')); + } + Y_UNIT_TEST(HandlingRepetitiveSet) { TPromise<int> promise = NewPromise<int>(); promise.SetValue(42); @@ -541,7 +541,7 @@ namespace { Y_UNIT_TEST(WaitAllowsExtract) { auto future = MakeFuture<int>(42); TVector vec{future, future, future}; - WaitExceptionOrAll(vec).GetValue(); + WaitExceptionOrAll(vec).GetValue(); WaitAny(vec).GetValue(); UNIT_ASSERT_EQUAL(future.ExtractValue(), 42); @@ -553,30 +553,30 @@ namespace { UNIT_ASSERT_EQUAL(future.ExtractValue(), 42); } - - Y_UNIT_TEST(WaitExceptionOrAllException) { - auto promise1 = NewPromise(); - auto promise2 = NewPromise(); - auto future1 = promise1.GetFuture(); - auto future2 = promise2.GetFuture(); - auto wait = WaitExceptionOrAll(future1, future2); - promise2.SetException("foo-exception"); - wait.Wait(); - UNIT_ASSERT(future2.HasException()); - UNIT_ASSERT(!future1.HasValue() && !future1.HasException()); - } - - Y_UNIT_TEST(WaitAllException) { - auto promise1 = NewPromise(); - auto promise2 = NewPromise(); - auto future1 = promise1.GetFuture(); - auto future2 = promise2.GetFuture(); - auto wait = WaitAll(future1, future2); - promise2.SetException("foo-exception"); - UNIT_ASSERT(!wait.HasValue() && !wait.HasException()); - promise1.SetValue(); - UNIT_ASSERT_EXCEPTION_CONTAINS(wait.GetValueSync(), yexception, "foo-exception"); - } + + Y_UNIT_TEST(WaitExceptionOrAllException) { + auto promise1 = NewPromise(); + auto promise2 = NewPromise(); + auto future1 = promise1.GetFuture(); + auto future2 = promise2.GetFuture(); + auto wait = WaitExceptionOrAll(future1, future2); + promise2.SetException("foo-exception"); + wait.Wait(); + UNIT_ASSERT(future2.HasException()); + UNIT_ASSERT(!future1.HasValue() && !future1.HasException()); + } + + Y_UNIT_TEST(WaitAllException) { + auto promise1 = NewPromise(); + auto promise2 = NewPromise(); + auto future1 = promise1.GetFuture(); + auto future2 = promise2.GetFuture(); + auto wait = WaitAll(future1, future2); + promise2.SetException("foo-exception"); + UNIT_ASSERT(!wait.HasValue() && !wait.HasException()); + promise1.SetValue(); + UNIT_ASSERT_EXCEPTION_CONTAINS(wait.GetValueSync(), yexception, "foo-exception"); + } Y_UNIT_TEST(FutureStateId) { TestFutureStateId<void>(); diff --git a/library/cpp/threading/future/subscription/ya.make b/library/cpp/threading/future/subscription/ya.make index db969b2319..cb75731dbf 100644 --- a/library/cpp/threading/future/subscription/ya.make +++ b/library/cpp/threading/future/subscription/ya.make @@ -13,10 +13,10 @@ SRCS( wait_any.cpp ) -PEERDIR( - library/cpp/threading/future -) - +PEERDIR( + library/cpp/threading/future +) + END() RECURSE_FOR_TESTS( diff --git a/library/cpp/threading/future/wait/wait-inl.h b/library/cpp/threading/future/wait/wait-inl.h index a6f9c55a6d..2753d5446c 100644 --- a/library/cpp/threading/future/wait/wait-inl.h +++ b/library/cpp/threading/future/wait/wait-inl.h @@ -13,17 +13,17 @@ namespace NThreading { for (const auto& future: futures) { voidFutures.push_back(future.IgnoreResult()); - } - + } + return voidFutures; } } - template <typename TContainer> + template <typename TContainer> [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures) { return WaitAll(NImpl::ToVoidFutures(futures)); - } - + } + template <typename TContainer> [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures) { return WaitExceptionOrAll(NImpl::ToVoidFutures(futures)); diff --git a/library/cpp/threading/future/wait/wait.cpp b/library/cpp/threading/future/wait/wait.cpp index d719719978..a173833a7f 100644 --- a/library/cpp/threading/future/wait/wait.cpp +++ b/library/cpp/threading/future/wait/wait.cpp @@ -23,11 +23,11 @@ namespace NThreading { TFuture<void> WaitGeneric(TArrayRef<const TFuture<void>> futures) { if (futures.empty()) { return MakeFuture(); - } + } if (futures.size() == 1) { return futures.front(); - } - + } + TWaitGroup<WaitPolicy> wg; for (const auto& fut : futures) { wg.Add(fut); @@ -41,19 +41,19 @@ namespace NThreading { TFuture<void> WaitAll(const TFuture<void>& f1) { return WaitGeneric<TWaitPolicy::TAll>(f1); - } - + } + TFuture<void> WaitAll(const TFuture<void>& f1, const TFuture<void>& f2) { return WaitGeneric<TWaitPolicy::TAll>(f1, f2); - } - + } + TFuture<void> WaitAll(TArrayRef<const TFuture<void>> futures) { return WaitGeneric<TWaitPolicy::TAll>(futures); - } - - - //////////////////////////////////////////////////////////////////////////////// - + } + + + //////////////////////////////////////////////////////////////////////////////// + TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1) { return WaitGeneric<TWaitPolicy::TExceptionOrAll>(f1); } diff --git a/library/cpp/threading/future/wait/wait.h b/library/cpp/threading/future/wait/wait.h index f69924a3d6..6ff7d57baa 100644 --- a/library/cpp/threading/future/wait/wait.h +++ b/library/cpp/threading/future/wait/wait.h @@ -14,16 +14,16 @@ namespace NThreading { !std::is_convertible_v<TContainer, TArrayRef<const TFuture<void>>>, TFuture<void>>; } - // waits for all futures - [[nodiscard]] TFuture<void> WaitAll(const TFuture<void>& f1); - [[nodiscard]] TFuture<void> WaitAll(const TFuture<void>& f1, const TFuture<void>& f2); + // waits for all futures + [[nodiscard]] TFuture<void> WaitAll(const TFuture<void>& f1); + [[nodiscard]] TFuture<void> WaitAll(const TFuture<void>& f1, const TFuture<void>& f2); [[nodiscard]] TFuture<void> WaitAll(TArrayRef<const TFuture<void>> futures); - template <typename TContainer> + template <typename TContainer> [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures); - - // waits for the first exception or for all futures - [[nodiscard]] TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1); - [[nodiscard]] TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1, const TFuture<void>& f2); + + // waits for the first exception or for all futures + [[nodiscard]] TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1); + [[nodiscard]] TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1, const TFuture<void>& f2); [[nodiscard]] TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures); template <typename TContainer> [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures); diff --git a/library/cpp/threading/local_executor/ya.make b/library/cpp/threading/local_executor/ya.make index e192634b94..df210f92bb 100644 --- a/library/cpp/threading/local_executor/ya.make +++ b/library/cpp/threading/local_executor/ya.make @@ -14,7 +14,7 @@ SRCS( PEERDIR( contrib/libs/tbb - library/cpp/threading/future + library/cpp/threading/future ) END() diff --git a/library/python/runtime_py3/__res.pyx b/library/python/runtime_py3/__res.pyx index e59e1a0590..97190d9f29 100644 --- a/library/python/runtime_py3/__res.pyx +++ b/library/python/runtime_py3/__res.pyx @@ -8,7 +8,7 @@ from util.generic.string cimport TString, TStringBuf cdef extern from "library/cpp/resource/resource.h" namespace "NResource": cdef size_t Count() except + cdef TStringBuf KeyByIndex(size_t idx) except + - cdef bool FindExact(const TStringBuf key, TString* result) nogil except + + cdef bool FindExact(const TStringBuf key, TString* result) nogil except + def count(): |