diff options
author | diver <diver@yandex-team.ru> | 2022-02-10 16:48:07 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:07 +0300 |
commit | e20e2b362f0232ed5a389db887e6e27e7763af18 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 | |
parent | 7629e1f9ef7f9d2a3c345c97e6a4e5a4b32ee786 (diff) | |
download | ydb-e20e2b362f0232ed5a389db887e6e27e7763af18.tar.gz |
Restoring authorship annotation for <diver@yandex-team.ru>. Commit 2 of 2.
-rw-r--r-- | contrib/libs/pire/pire/fsm.cpp | 34 | ||||
-rw-r--r-- | library/cpp/binsaver/bin_saver.h | 40 | ||||
-rw-r--r-- | library/cpp/binsaver/ut/binsaver_ut.cpp | 84 | ||||
-rw-r--r-- | library/cpp/binsaver/ut/ya.make | 16 | ||||
-rw-r--r-- | library/cpp/compproto/compproto_ut.cpp | 36 | ||||
-rw-r--r-- | library/cpp/deprecated/split/delim_string_iter.h | 50 | ||||
-rw-r--r-- | library/cpp/deprecated/split/delim_string_iter_ut.cpp | 14 | ||||
-rw-r--r-- | library/cpp/getopt/small/modchooser.cpp | 4 | ||||
-rw-r--r-- | library/cpp/getopt/ut/last_getopt_ut.cpp | 20 | ||||
-rw-r--r-- | library/cpp/on_disk/chunks/reader.cpp | 6 | ||||
-rw-r--r-- | library/cpp/on_disk/chunks/reader.h | 6 | ||||
-rw-r--r-- | library/cpp/packedtypes/packed.h | 10 | ||||
-rw-r--r-- | library/cpp/protobuf/util/pb_io.cpp | 22 | ||||
-rw-r--r-- | library/cpp/protobuf/util/pb_io.h | 8 | ||||
-rw-r--r-- | library/cpp/regex/pire/ut/regexp_ut.cpp | 24 | ||||
-rw-r--r-- | util/draft/enum.h | 22 | ||||
-rw-r--r-- | util/folder/path.cpp | 10 | ||||
-rw-r--r-- | util/folder/tempdir.h | 6 | ||||
-rw-r--r-- | util/generic/lazy_value.cpp | 2 | ||||
-rw-r--r-- | util/generic/lazy_value.h | 86 | ||||
-rw-r--r-- | util/generic/lazy_value_ut.cpp | 66 |
21 files changed, 283 insertions, 283 deletions
diff --git a/contrib/libs/pire/pire/fsm.cpp b/contrib/libs/pire/pire/fsm.cpp index 7797d0beae..984d708dfa 100644 --- a/contrib/libs/pire/pire/fsm.cpp +++ b/contrib/libs/pire/pire/fsm.cpp @@ -981,28 +981,28 @@ public: mNewFsm.Connect(from, to, letter); } typedef bool Result; - - Result Success() { - Fsm::Outputs oldOutputs; - // remove redundant outputs - oldOutputs.swap(mNewFsm.outputs); - for (size_t from = 0; from < mNewFsm.Size(); ++from) { + + Result Success() { + Fsm::Outputs oldOutputs; + // remove redundant outputs + oldOutputs.swap(mNewFsm.outputs); + for (size_t from = 0; from < mNewFsm.Size(); ++from) { auto fromOutput = oldOutputs.find(from); - if (fromOutput == oldOutputs.end()) - continue; + if (fromOutput == oldOutputs.end()) + continue; const auto& newTransitionsRow = mNewFsm.m_transitions[from]; for (auto&& row : newTransitionsRow) { for (auto&& stateIt : row.second) { auto toOutput = fromOutput->second.find(stateIt); - if (toOutput != fromOutput->second.end()) { - mNewFsm.outputs[from].insert(*toOutput); - } - } - } - } - return true; - } - + if (toOutput != fromOutput->second.end()) { + mNewFsm.outputs[from].insert(*toOutput); + } + } + } + } + return true; + } + Result Failure() { return false; } Fsm& Output() { return mNewFsm; } diff --git a/library/cpp/binsaver/bin_saver.h b/library/cpp/binsaver/bin_saver.h index 88759d9049..412424889f 100644 --- a/library/cpp/binsaver/bin_saver.h +++ b/library/cpp/binsaver/bin_saver.h @@ -66,22 +66,22 @@ private: void CallObjectSerialize(T* p, NBinSaverInternals::TOverloadPriority<2>) { // highest priority - will be resolved first if enabled // Note: p->operator &(*this) would lead to infinite recursion p->T::operator&(*this); - } - + } + template <class T, typename = decltype(std::declval<T&>() & std::declval<IBinSaver&>())> void CallObjectSerialize(T* p, NBinSaverInternals::TOverloadPriority<1>) { // lower priority - will be resolved second if enabled - (*p) & (*this); - } - + (*p) & (*this); + } + template <class T> void CallObjectSerialize(T* p, NBinSaverInternals::TOverloadPriority<0>) { // lower priority - will be resolved last -#if (!defined(_MSC_VER)) - // In MSVC __has_trivial_copy returns false to enums, primitive types and arrays. +#if (!defined(_MSC_VER)) + // In MSVC __has_trivial_copy returns false to enums, primitive types and arrays. static_assert(__has_trivial_copy(T), "Class is nontrivial copyable, you must define operator&, see"); #endif - DataChunk(p, sizeof(T)); - } - + DataChunk(p, sizeof(T)); + } + // vector template <class T, class TA> void DoVector(TVector<T, TA>& data) { @@ -327,7 +327,7 @@ public: } template <class T1, class TA> int Add(const chunk_id, TVector<T1, TA>* pVec) { - if (HasNonTrivialSerializer<T1>(0u)) + if (HasNonTrivialSerializer<T1>(0u)) DoVector(*pVec); else DoDataVector(*pVec); @@ -371,7 +371,7 @@ public: template <class T1> int Add(const chunk_id, TArray2D<T1>* pArr) { - if (HasNonTrivialSerializer<T1>(0u)) + if (HasNonTrivialSerializer<T1>(0u)) Do2DArray(*pArr); else Do2DArrayData(*pArr); @@ -403,7 +403,7 @@ public: template <class T1, size_t N> int Add(const chunk_id, std::array<T1, N>* pData) { - if (HasNonTrivialSerializer<T1>(0u)) { + if (HasNonTrivialSerializer<T1>(0u)) { for (size_t i = 0; i < N; ++i) Add(1, &(*pData)[i]); } else { @@ -494,11 +494,11 @@ public: void AddPolymorphicBase(chunk_id, IObjectBase* pObject) { (*pObject) & (*this); } - + template <class T1, class T2> void DoPtr(TPtrBase<T1, T2>* pData) { - if (pData && pData->Get()) { - } + if (pData && pData->Get()) { + } if (IsReading()) pData->Set(CastToUserObject(LoadObject(), (T1*)nullptr)); else @@ -536,14 +536,14 @@ public: } template <class T, typename = decltype(std::declval<T&>() & std::declval<IBinSaver&>())> - static bool HasNonTrivialSerializer(ui32) { - return true; + static bool HasNonTrivialSerializer(ui32) { + return true; } template <class T> - static bool HasNonTrivialSerializer(...) { + static bool HasNonTrivialSerializer(...) { return sizeof(std::declval<IBinSaver*>()->Add(0, std::declval<T*>())) != 1; - } + } public: IBinSaver(IBinaryStream& stream, bool _bRead, bool stableOutput = false) diff --git a/library/cpp/binsaver/ut/binsaver_ut.cpp b/library/cpp/binsaver/ut/binsaver_ut.cpp index 218937d244..37eba5406f 100644 --- a/library/cpp/binsaver/ut/binsaver_ut.cpp +++ b/library/cpp/binsaver/ut/binsaver_ut.cpp @@ -3,42 +3,42 @@ #include <library/cpp/binsaver/bin_saver.h> #include <library/cpp/binsaver/ut_util/ut_util.h> #include <library/cpp/testing/unittest/registar.h> - -#include <util/stream/buffer.h> + +#include <util/stream/buffer.h> #include <util/generic/map.h> - -struct TBinarySerializable { - ui32 Data = 0; -}; - -struct TNonBinarySerializable { - ui32 Data = 0; + +struct TBinarySerializable { + ui32 Data = 0; +}; + +struct TNonBinarySerializable { + ui32 Data = 0; TString StrData; -}; - -struct TCustomSerializer { - ui32 Data = 0; +}; + +struct TCustomSerializer { + ui32 Data = 0; TString StrData; - SAVELOAD(StrData, Data); -}; - -struct TCustomOuterSerializer { - ui32 Data = 0; + SAVELOAD(StrData, Data); +}; + +struct TCustomOuterSerializer { + ui32 Data = 0; TString StrData; -}; - +}; + void operator&(TCustomOuterSerializer& s, IBinSaver& f); - -struct TCustomOuterSerializerTmpl { - ui32 Data = 0; + +struct TCustomOuterSerializerTmpl { + ui32 Data = 0; TString StrData; -}; - +}; + struct TCustomOuterSerializerTmplDerived: public TCustomOuterSerializerTmpl { - ui32 Data = 0; + ui32 Data = 0; TString StrData; -}; - +}; + struct TMoveOnlyType { ui32 Data = 0; @@ -62,11 +62,11 @@ struct TTypeWithArray { template <typename T, typename = std::enable_if_t<std::is_base_of<TCustomOuterSerializerTmpl, T>::value>> int operator&(T& s, IBinSaver& f); - + static bool operator==(const TBlob& l, const TBlob& r) { return TStringBuf(l.AsCharPtr(), l.Size()) == TStringBuf(r.AsCharPtr(), r.Size()); } - + Y_UNIT_TEST_SUITE(BinSaver){ Y_UNIT_TEST(HasTrivialSerializer){ UNIT_ASSERT(!IBinSaver::HasNonTrivialSerializer<TBinarySerializable>(0u)); @@ -77,12 +77,12 @@ UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TCustomOuterSerializerTmpl>(0u)); UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TCustomOuterSerializerTmplDerived>(0u)); UNIT_ASSERT(IBinSaver::HasNonTrivialSerializer<TVector<TCustomSerializer>>(0u)); } - - + + Y_UNIT_TEST(TestStroka) { TestBinSaverSerialization(TString("QWERTY")); } - + Y_UNIT_TEST(TestMoveOnlyType) { TestBinSaverSerializationToBuffer(TMoveOnlyType()); } @@ -104,11 +104,11 @@ Y_UNIT_TEST(TestMaps) { TestBinSaverSerialization(THashMap<TString, ui32>{{"A", 1}, {"B", 2}, {"C", 3}}); TestBinSaverSerialization(TMap<TString, ui32>{{"A", 1}, {"B", 2}, {"C", 3}}); } - + Y_UNIT_TEST(TestBlob) { TestBinSaverSerialization(TBlob::FromStringSingleThreaded("qwerty")); } - + Y_UNIT_TEST(TestVariant) { { using T = std::variant<TString, int>; @@ -140,15 +140,15 @@ Y_UNIT_TEST(TestPod) { TestBinSaverSerialization(custom); TestBinSaverSerialization(TVector<TPod>{custom}); } - + Y_UNIT_TEST(TestSubPod) { struct TPod { struct TSub { ui32 X = 10; bool operator==(const TSub& other) const { return X == other.X; - } - }; + } + }; TVector<TSub> B; int operator&(IBinSaver& f) { f.Add(0, &B); @@ -165,7 +165,7 @@ Y_UNIT_TEST(TestSubPod) { custom.B = {sub}; TestBinSaverSerialization(TVector<TPod>{custom}); } - + Y_UNIT_TEST(TestMemberAndOpIsMain) { struct TBase { TString S; @@ -175,7 +175,7 @@ Y_UNIT_TEST(TestMemberAndOpIsMain) { } virtual ~TBase() = default; }; - + struct TDerived: public TBase { int A = 0; int operator&(IBinSaver& f)override { @@ -187,11 +187,11 @@ Y_UNIT_TEST(TestMemberAndOpIsMain) { return A == other.A && S == other.S; } }; - + TDerived obj; obj.S = "TString"; obj.A = 42; - + TestBinSaverSerialization(obj); } } diff --git a/library/cpp/binsaver/ut/ya.make b/library/cpp/binsaver/ut/ya.make index d0b48e78aa..43dc20bff7 100644 --- a/library/cpp/binsaver/ut/ya.make +++ b/library/cpp/binsaver/ut/ya.make @@ -1,11 +1,11 @@ UNITTEST_FOR(library/cpp/binsaver) - -OWNER(gulin) - -SRCS( - binsaver_ut.cpp -) - + +OWNER(gulin) + +SRCS( + binsaver_ut.cpp +) + PEERDIR(library/cpp/binsaver/ut_util) -END() +END() diff --git a/library/cpp/compproto/compproto_ut.cpp b/library/cpp/compproto/compproto_ut.cpp index 7380fb6cc2..9393be967a 100644 --- a/library/cpp/compproto/compproto_ut.cpp +++ b/library/cpp/compproto/compproto_ut.cpp @@ -34,15 +34,15 @@ struct TTestParams { template <typename X> void TestSaveLoadMeta(NCompProto::TMetaInfo<X>& src) { - TStringStream ss; - src.Save(ss); + TStringStream ss; + src.Save(ss); TString data = ss.Str(); - NCompProto::TMetaInfo<X> loadedMeta(data); - ss = TStringStream(); - loadedMeta.Save(ss); - UNIT_ASSERT_EQUAL(ss.Str(), data); -} - + NCompProto::TMetaInfo<X> loadedMeta(data); + ss = TStringStream(); + loadedMeta.Save(ss); + UNIT_ASSERT_EQUAL(ss.Str(), data); +} + template <typename TDecompressor, template <typename, typename> class TSerialize> void TestWithParams(const TString& metainfo, const ECompMode mode, const TTestParams& params) { using namespace NCompProto; @@ -59,7 +59,7 @@ void TestWithParams(const TString& metainfo, const ECompMode mode, const TTestPa } else { meta.Reset(new TMetaInfo<THuff>(stream)); } - TestSaveLoadMeta(*meta.Get()); + TestSaveLoadMeta(*meta.Get()); TBitBuffer buffer; TSerialize<THuff, TBitBuffer>::Serialize(*meta, buffer, params); @@ -120,7 +120,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { scalar clicks id 0 default const 0\n\ scalar shows id 1 default const 0\n\ end\n\ - scalar extra id 31 default const 0\n\ + scalar extra id 31 default const 0\n\ end\n"; struct TRegInfo { @@ -131,7 +131,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { struct TData { ui32 Clicks; ui32 Shows; - ui32 Extra; + ui32 Extra; TMap<ui32, TRegInfo> RegClicks; }; @@ -149,7 +149,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { data[i].Clicks = PseudoRandom(16) + 100; data[i].Shows = PseudoRandom(500) * PseudoRandom(16); - data[i].Extra = PseudoRandom(500) + (1UL << 31); // test also saving of big values + data[i].Extra = PseudoRandom(500) + (1UL << 31); // test also saving of big values meta.SetScalar(0, data[i].Clicks, functor); meta.SetScalar(1, data[i].Shows, functor); @@ -166,7 +166,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { regClicks.EndElement(functor); } regClicks.EndRepeated(functor); - meta.SetScalar(31, data[i].Extra, functor); + meta.SetScalar(31, data[i].Extra, functor); meta.EndElement(functor); } meta.EndRepeated(functor); @@ -224,8 +224,8 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { UNIT_ASSERT_EQUAL(val, Elem->Clicks); if (index == 1) UNIT_ASSERT_EQUAL(val, Elem->Shows); - if (index == 31) - UNIT_ASSERT_EQUAL(val, Elem->Extra); + if (index == 31) + UNIT_ASSERT_EQUAL(val, Elem->Extra); } IDecompressor& GetDecompressor(size_t index) { if (index == 2) { @@ -323,7 +323,7 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { case InDataElem: State = OutDataElem; ++DataInd; - break; + break; case InRegClicks: ++RegIter; break; @@ -339,8 +339,8 @@ Y_UNIT_TEST_SUITE(CompProtoTestBasic) { UNIT_ASSERT_EQUAL(val, data[DataInd].Clicks); if (index == 1) UNIT_ASSERT_EQUAL(val, data[DataInd].Shows); - if (index == 31) - UNIT_ASSERT_EQUAL(val, data[DataInd].Extra); + if (index == 31) + UNIT_ASSERT_EQUAL(val, data[DataInd].Extra); break; case InRegClicks: if (index == 0) diff --git a/library/cpp/deprecated/split/delim_string_iter.h b/library/cpp/deprecated/split/delim_string_iter.h index ccdcbb5b45..8e4ca171a0 100644 --- a/library/cpp/deprecated/split/delim_string_iter.h +++ b/library/cpp/deprecated/split/delim_string_iter.h @@ -9,7 +9,7 @@ #include <iterator> class TDelimStringIter { -public: +public: using value_type = TStringBuf; using difference_type = ptrdiff_t; using pointer = const TStringBuf*; @@ -23,14 +23,14 @@ public: inline TDelimStringIter(TStringBuf str, TStringBuf delim) : IsValid(true) - , Str(str) + , Str(str) , Delim(delim) { - UpdateCurrent(); + UpdateCurrent(); } inline TDelimStringIter() - : IsValid(false) + : IsValid(false) { } @@ -40,12 +40,12 @@ public: // NOTE: this is a potentially unsafe operation (no overrun check) inline TDelimStringIter& operator++() { - if (Current.end() != Str.end()) { - Str.Skip(Current.length() + Delim.length()); - UpdateCurrent(); + if (Current.end() != Str.end()) { + Str.Skip(Current.length() + Delim.length()); + UpdateCurrent(); } else { - Str.Clear(); - Current.Clear(); + Str.Clear(); + Current.Clear(); IsValid = false; } return *this; @@ -58,26 +58,26 @@ public: } inline bool operator==(const TDelimStringIter& rhs) const { - return (IsValid == rhs.IsValid) && (!IsValid || (Current.begin() == rhs.Current.begin())); + return (IsValid == rhs.IsValid) && (!IsValid || (Current.begin() == rhs.Current.begin())); } inline bool operator!=(const TDelimStringIter& rhs) const { - return !(*this == rhs); + return !(*this == rhs); } inline TStringBuf operator*() const { - return Current; + return Current; } inline const TStringBuf* operator->() const { - return &Current; - } - + return &Current; + } + // Get & advance template <class T> inline bool TryNext(T& t) { if (IsValid) { - t = FromString<T>(Current); + t = FromString<T>(Current); operator++(); return true; } else { @@ -95,26 +95,26 @@ public: template <class T> inline T GetNext() { - T res; - Next(res); - return res; - } - + T res; + Next(res); + return res; + } + inline const char* GetBegin() const { - return Current.begin(); + return Current.begin(); } inline const char* GetEnd() const { - return Current.end(); + return Current.end(); } inline bool Valid() const { return IsValid; } - // contents from next token to the end of string + // contents from next token to the end of string inline TStringBuf Cdr() const { - return Str.SubStr(Current.length() + Delim.length()); + return Str.SubStr(Current.length() + Delim.length()); } inline TDelimStringIter IterEnd() const { diff --git a/library/cpp/deprecated/split/delim_string_iter_ut.cpp b/library/cpp/deprecated/split/delim_string_iter_ut.cpp index fece177f4d..18a8b2a160 100644 --- a/library/cpp/deprecated/split/delim_string_iter_ut.cpp +++ b/library/cpp/deprecated/split/delim_string_iter_ut.cpp @@ -10,7 +10,7 @@ static void AssertStringSplit(const TString& str, const TString& delim, const TV for (const auto& expectedString : expected) { UNIT_ASSERT(it.Valid()); UNIT_ASSERT(bool(it)); - UNIT_ASSERT_STRINGS_EQUAL(it->ToString(), expectedString); + UNIT_ASSERT_STRINGS_EQUAL(it->ToString(), expectedString); ++it; } UNIT_ASSERT(!it.Valid()); @@ -30,14 +30,14 @@ Y_UNIT_TEST_SUITE(TDelimStrokaIterTestSuite) { Y_UNIT_TEST(NoDelimitersPresent) { AssertStringSplit("This string could be yours", "\t", {"This string could be yours"}); } - + Y_UNIT_TEST(Cdr) { TDelimStringIter it("a\tc\t", "\t"); - UNIT_ASSERT_STRINGS_EQUAL(*it, "a"); - UNIT_ASSERT_STRINGS_EQUAL(it.Cdr(), "c\t"); - ++it; - UNIT_ASSERT_STRINGS_EQUAL(it.Cdr(), ""); - } + UNIT_ASSERT_STRINGS_EQUAL(*it, "a"); + UNIT_ASSERT_STRINGS_EQUAL(it.Cdr(), "c\t"); + ++it; + UNIT_ASSERT_STRINGS_EQUAL(it.Cdr(), ""); + } Y_UNIT_TEST(ForIter) { TVector<TStringBuf> expected = {"1", "", "3@4", ""}; diff --git a/library/cpp/getopt/small/modchooser.cpp b/library/cpp/getopt/small/modchooser.cpp index 5595ed8d95..2fa5cfd070 100644 --- a/library/cpp/getopt/small/modchooser.cpp +++ b/library/cpp/getopt/small/modchooser.cpp @@ -181,7 +181,7 @@ int TModChooser::Run(const int argc, const char** argv) const { } if (modeName == "-h" || modeName == "--help" || modeName == "-?") { - PrintHelp(argv[0]); + PrintHelp(argv[0]); return 0; } if (VersionHandler && (modeName == "-v" || modeName == "--version")) { @@ -200,7 +200,7 @@ int TModChooser::Run(const int argc, const char** argv) const { if (modeIter == Modes.end()) { Cerr << "Unknown mode " << modeName.Quote() << "." << Endl; - PrintHelp(argv[0]); + PrintHelp(argv[0]); return 1; } diff --git a/library/cpp/getopt/ut/last_getopt_ut.cpp b/library/cpp/getopt/ut/last_getopt_ut.cpp index 64b46c7da6..c99a1d053d 100644 --- a/library/cpp/getopt/ut/last_getopt_ut.cpp +++ b/library/cpp/getopt/ut/last_getopt_ut.cpp @@ -591,19 +591,19 @@ Y_UNIT_TEST_SUITE(TLastGetoptTests) { } Y_UNIT_TEST(TestCustomCmdLineDescr) { - TOpts opts; - const char* prog = "my_program"; + TOpts opts; + const char* prog = "my_program"; TString customDescr = "<FILE|TABLE> USER [OPTIONS]"; - int argc = 2; + int argc = 2; const char* cmd[] = {prog}; - opts.SetCmdLineDescr(customDescr); - TOptsParser parser(&opts, argc, cmd); - TStringStream out; - parser.PrintUsage(out); - // find custom usage + opts.SetCmdLineDescr(customDescr); + TOptsParser parser(&opts, argc, cmd); + TStringStream out; + parser.PrintUsage(out); + // find custom usage UNIT_ASSERT(out.Str().find(customDescr) != TString::npos); - } - + } + Y_UNIT_TEST(TestColorPrint) { TOpts opts; const char* prog = "my_program"; diff --git a/library/cpp/on_disk/chunks/reader.cpp b/library/cpp/on_disk/chunks/reader.cpp index 4ae7f843ee..6e28cbf367 100644 --- a/library/cpp/on_disk/chunks/reader.cpp +++ b/library/cpp/on_disk/chunks/reader.cpp @@ -47,6 +47,6 @@ TChunkedDataReader::TChunkedDataReader(const TBlob& blob) { } } -TBlob TChunkedDataReader::GetBlob(size_t index) const { - return TBlob::NoCopy(GetBlock(index), GetBlockLen(index)); -} +TBlob TChunkedDataReader::GetBlob(size_t index) const { + return TBlob::NoCopy(GetBlock(index), GetBlockLen(index)); +} diff --git a/library/cpp/on_disk/chunks/reader.h b/library/cpp/on_disk/chunks/reader.h index 34690a5847..c5fe783319 100644 --- a/library/cpp/on_disk/chunks/reader.h +++ b/library/cpp/on_disk/chunks/reader.h @@ -28,16 +28,16 @@ public: return Lengths[index]; } - + TBlob GetBlob(size_t index) const; - + template <typename T> TArrayRef<const T> GetRegion(size_t index) const { size_t len = GetBlockLen(index); Y_ENSURE(len % sizeof(T) == 0, "wrong data padding"); return TArrayRef<const T>(reinterpret_cast<const T*>(GetBlock(index)), len / sizeof(T)); } - + inline size_t GetBlocksCount() const { return Offsets.size(); } diff --git a/library/cpp/packedtypes/packed.h b/library/cpp/packedtypes/packed.h index 1e1619ce04..88cff26ae2 100644 --- a/library/cpp/packedtypes/packed.h +++ b/library/cpp/packedtypes/packed.h @@ -89,10 +89,10 @@ void Y_FORCE_INLINE UnPackUI32(TStream& in, ui32& v) { UNPACK_28(v, in, TInputStream2Traits<TStream>::TTraits, size); (void)size; } - + template <class TStream> ui32 Y_FORCE_INLINE UnPackUI32(TStream& in) { - ui32 res; - UnPackUI32(in, res); - return res; -} + ui32 res; + UnPackUI32(in, res); + return res; +} diff --git a/library/cpp/protobuf/util/pb_io.cpp b/library/cpp/protobuf/util/pb_io.cpp index 6528db53e0..6270ee0624 100644 --- a/library/cpp/protobuf/util/pb_io.cpp +++ b/library/cpp/protobuf/util/pb_io.cpp @@ -26,7 +26,7 @@ namespace NProtoBuf { ythrow yexception() << "can't parse " << m.GetTypeName() << " from base64-encoded string"; } } - + bool TryParseFromBase64String(const TStringBuf dataBase64, Message& m, bool allowUneven) { try { ParseFromBase64String(dataBase64, m, allowUneven); @@ -35,7 +35,7 @@ namespace NProtoBuf { return false; } } - + void SerializeToBase64String(const Message& m, TString& dataBase64) { TString rawData; if (!m.SerializeToString(&rawData)) { @@ -82,17 +82,17 @@ namespace NProtoBuf { } int operator&(NProtoBuf::Message& m, IBinSaver& f) { - TStringStream ss; - if (f.IsReading()) { - f.Add(0, &ss.Str()); + TStringStream ss; + if (f.IsReading()) { + f.Add(0, &ss.Str()); m.ParseFromArcadiaStream(&ss); - } else { + } else { m.SerializeToArcadiaStream(&ss); - f.Add(0, &ss.Str()); - } - return 0; -} - + f.Add(0, &ss.Str()); + } + return 0; +} + void SerializeToTextFormat(const NProtoBuf::Message& m, IOutputStream& out) { NProtoBuf::io::TCopyingOutputStreamAdaptor adaptor(&out); diff --git a/library/cpp/protobuf/util/pb_io.h b/library/cpp/protobuf/util/pb_io.h index 9c336382c7..493c84cb5f 100644 --- a/library/cpp/protobuf/util/pb_io.h +++ b/library/cpp/protobuf/util/pb_io.h @@ -4,10 +4,10 @@ #include <util/generic/flags.h> struct IBinSaver; - + namespace google { namespace protobuf { - class Message; + class Message; } } @@ -41,9 +41,9 @@ namespace NProtoBuf { bool MergePartialFromString(NProtoBuf::Message& m, const TStringBuf serializedProtoMessage); bool MergeFromString(NProtoBuf::Message& m, const TStringBuf serializedProtoMessage); } - + int operator&(NProtoBuf::Message& m, IBinSaver& f); - + // Write a textual representation of the given message to the given file. void SerializeToTextFormat(const NProtoBuf::Message& m, const TString& fileName); void SerializeToTextFormat(const NProtoBuf::Message& m, IOutputStream& out); diff --git a/library/cpp/regex/pire/ut/regexp_ut.cpp b/library/cpp/regex/pire/ut/regexp_ut.cpp index 651e986cef..e7206de9ad 100644 --- a/library/cpp/regex/pire/ut/regexp_ut.cpp +++ b/library/cpp/regex/pire/ut/regexp_ut.cpp @@ -141,21 +141,21 @@ Y_UNIT_TEST_SUITE(TRegExp) { } Y_UNIT_TEST(Capture6) { - TCapturingFsm fsm("(/to-match-with)"); - TSearcher searcher(fsm); - searcher.Search("/some/table/path/to-match-with"); - UNIT_ASSERT(searcher.Captured()); + TCapturingFsm fsm("(/to-match-with)"); + TSearcher searcher(fsm); + searcher.Search("/some/table/path/to-match-with"); + UNIT_ASSERT(searcher.Captured()); UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("/to-match-with")); - } - + } + Y_UNIT_TEST(Capture7) { - TCapturingFsm fsm("(pref.*suff)"); - TSearcher searcher(fsm); - searcher.Search("ala pref bla suff cla"); - UNIT_ASSERT(searcher.Captured()); + TCapturingFsm fsm("(pref.*suff)"); + TSearcher searcher(fsm); + searcher.Search("ala pref bla suff cla"); + UNIT_ASSERT(searcher.Captured()); //UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("pref bla suff")); - } - + } + Y_UNIT_TEST(CaptureXA) { TCapturingFsm fsm(".*(xa).*"); diff --git a/util/draft/enum.h b/util/draft/enum.h index 82e4de14fd..18002b7df2 100644 --- a/util/draft/enum.h +++ b/util/draft/enum.h @@ -119,18 +119,18 @@ inline void SetEnumFlags(const std::pair<const char*, E>* str2Enum, TStringBuf o } } -// for enums generated with GENERATE_ENUM_SERIALIZATION -template <class E, size_t B> -inline void SetEnumFlags(TStringBuf optSpec, std::bitset<B>& flags, bool allIfEmpty = true) { - if (optSpec.empty()) { +// for enums generated with GENERATE_ENUM_SERIALIZATION +template <class E, size_t B> +inline void SetEnumFlags(TStringBuf optSpec, std::bitset<B>& flags, bool allIfEmpty = true) { + if (optSpec.empty()) { SetEnumFlagsForEmptySpec(flags, allIfEmpty); - } else { - flags.reset(); + } else { + flags.reset(); for (const auto& it : StringSplitter(optSpec).Split(',')) { - E e; + E e; if (!TryFromString(it.Token(), e)) ythrow yexception() << "Unknown enum value '" << it.Token() << "'"; - flags.set((size_t)e); - } - } -} + flags.set((size_t)e); + } + } +} diff --git a/util/folder/path.cpp b/util/folder/path.cpp index 5227f2df3a..bfe0c67d68 100644 --- a/util/folder/path.cpp +++ b/util/folder/path.cpp @@ -333,12 +333,12 @@ bool TFsPath::Exists() const { return IsDefined() && NFs::Exists(*this); } -void TFsPath::CheckExists() const { - if (!Exists()) { +void TFsPath::CheckExists() const { + if (!Exists()) { ythrow TIoException() << "path does not exist " << Path_; - } -} - + } +} + bool TFsPath::IsDirectory() const { return IsDefined() && TFileStat(GetPath().data()).IsDir(); } diff --git a/util/folder/tempdir.h b/util/folder/tempdir.h index 9ce01ef655..ff458f83b9 100644 --- a/util/folder/tempdir.h +++ b/util/folder/tempdir.h @@ -18,9 +18,9 @@ public: static TTempDir NewTempDir(const TString& root); const TString& operator()() const { - return Name(); - } - + return Name(); + } + const TString& Name() const { return TempDir.GetPath(); } diff --git a/util/generic/lazy_value.cpp b/util/generic/lazy_value.cpp index 6b6738404e..e687ec1a59 100644 --- a/util/generic/lazy_value.cpp +++ b/util/generic/lazy_value.cpp @@ -1 +1 @@ -#include "lazy_value.h" +#include "lazy_value.h" diff --git a/util/generic/lazy_value.h b/util/generic/lazy_value.h index 033b46eaf2..3c720f76b5 100644 --- a/util/generic/lazy_value.h +++ b/util/generic/lazy_value.h @@ -1,53 +1,53 @@ -#pragma once - -#include "maybe.h" +#pragma once + +#include "maybe.h" #include "function.h" - -template <class T> + +template <class T> class TLazyValueBase { -public: +public: using TInitializer = std::function<T()>; - + TLazyValueBase() = default; TLazyValueBase(TInitializer initializer) : Initializer(std::move(initializer)) - { - } - - explicit operator bool() const noexcept { - return Defined(); - } - - bool Defined() const noexcept { - return ValueHolder.Defined(); - } - - const T& GetRef() const { - if (!Defined()) { - InitDefault(); - } - return *ValueHolder; - } - - const T& operator*() const { - return GetRef(); - } - - const T* operator->() const { - return &GetRef(); - } - - void InitDefault() const { + { + } + + explicit operator bool() const noexcept { + return Defined(); + } + + bool Defined() const noexcept { + return ValueHolder.Defined(); + } + + const T& GetRef() const { + if (!Defined()) { + InitDefault(); + } + return *ValueHolder; + } + + const T& operator*() const { + return GetRef(); + } + + const T* operator->() const { + return &GetRef(); + } + + void InitDefault() const { Y_ASSERT(Initializer); - ValueHolder = Initializer(); - } - -private: - mutable TMaybe<T> ValueHolder; - TInitializer Initializer; -}; - + ValueHolder = Initializer(); + } + +private: + mutable TMaybe<T> ValueHolder; + TInitializer Initializer; +}; + // we need this to get implicit construction TLazyValue from lambda // and save default copy constructor and operator= for type TLazyValue template <class T> @@ -63,4 +63,4 @@ public: template <typename F> TLazyValue<TFunctionResult<F>> MakeLazy(F&& f) { return {std::forward<F>(f)}; -} +} diff --git a/util/generic/lazy_value_ut.cpp b/util/generic/lazy_value_ut.cpp index ba159f19f7..f6135880c3 100644 --- a/util/generic/lazy_value_ut.cpp +++ b/util/generic/lazy_value_ut.cpp @@ -1,22 +1,22 @@ -#include "lazy_value.h" - +#include "lazy_value.h" + #include <library/cpp/testing/unittest/registar.h> - + Y_UNIT_TEST_SUITE(TLazyValueTestSuite) { Y_UNIT_TEST(TestLazyValue) { TLazyValue<int> value([]() { - return 5; - }); - UNIT_ASSERT(!value); - UNIT_ASSERT_EQUAL(*value, 5); - UNIT_ASSERT(value); - } - + return 5; + }); + UNIT_ASSERT(!value); + UNIT_ASSERT_EQUAL(*value, 5); + UNIT_ASSERT(value); + } + Y_UNIT_TEST(TestLazyValueInitialization) { TLazyValue<int> value1([]() { return 5; }); - + TLazyValue<int> value2 = []() { return 5; }; - + TLazyValue<int> notInitialized{}; TLazyValue<int> copy1(value1); @@ -90,17 +90,17 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) { } class TValueProvider { - public: + public: static size_t CountParseDataCalled; - TValueProvider() + TValueProvider() : Data_([&] { return this->ParseData(); }) - { - } - + { + } + const TString& GetData() const { return *Data_; - } + } private: TLazyValue<TString> Data_; @@ -109,16 +109,16 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) { CountParseDataCalled++; return "hi"; } - }; - + }; + size_t TValueProvider::CountParseDataCalled = 0; Y_UNIT_TEST(TestValueProvider) { - TValueProvider provider; - - UNIT_ASSERT(provider.GetData() == "hi"); - } - + TValueProvider provider; + + UNIT_ASSERT(provider.GetData() == "hi"); + } + Y_UNIT_TEST(TestValueProviderCopy) { TValueProvider provider; provider.GetData(); @@ -147,11 +147,11 @@ Y_UNIT_TEST_SUITE(TLazyValueTestSuite) { } Y_UNIT_TEST(TestMakeLazy) { - auto lv = MakeLazy([] { - return 100500; - }); - UNIT_ASSERT(!lv); - UNIT_ASSERT(lv.GetRef() == 100500); - UNIT_ASSERT(lv); - } -} + auto lv = MakeLazy([] { + return 100500; + }); + UNIT_ASSERT(!lv); + UNIT_ASSERT(lv.GetRef() == 100500); + UNIT_ASSERT(lv); + } +} |