diff options
author | tobo <tobo@yandex-team.ru> | 2022-02-10 16:47:27 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:27 +0300 |
commit | 7fe839092527589b38f014d854c51565b3c1adfa (patch) | |
tree | 309e97022d3530044b712b8f71318c78faf7856e /util | |
parent | d0d68c395c10da4cb56a1c845504570a04d7893e (diff) | |
download | ydb-7fe839092527589b38f014d854c51565b3c1adfa.tar.gz |
Restoring authorship annotation for <tobo@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
93 files changed, 459 insertions, 459 deletions
diff --git a/util/charset/generated/unidata.cpp b/util/charset/generated/unidata.cpp index 6f5adbbc0a..ea2158ab80 100644 --- a/util/charset/generated/unidata.cpp +++ b/util/charset/generated/unidata.cpp @@ -1,7 +1,7 @@ #include <util/charset/unidata.h> namespace { namespace NUnidataTableGenerated { - using TV = const NUnicode::NPrivate::TUnidataTable::TStored; + using TV = const NUnicode::NPrivate::TUnidataTable::TStored; static const TV V[] = { #undef V0 diff --git a/util/charset/utf8_ut.cpp b/util/charset/utf8_ut.cpp index 9e68881cca..fab9164e49 100644 --- a/util/charset/utf8_ut.cpp +++ b/util/charset/utf8_ut.cpp @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) { Y_UNIT_TEST(TestToLowerUtfString) { UNIT_ASSERT_VALUES_EQUAL(ToLowerUTF8("xyz XYZ ПРИВЕТ!"), "xyz xyz привет!"); - UNIT_ASSERT_VALUES_EQUAL(ToLowerUTF8(TStringBuf("xyz")), "xyz"); + UNIT_ASSERT_VALUES_EQUAL(ToLowerUTF8(TStringBuf("xyz")), "xyz"); { TString s = "привет!"; @@ -55,7 +55,7 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) { Y_UNIT_TEST(TestToUpperUtfString) { UNIT_ASSERT_VALUES_EQUAL(ToUpperUTF8("xyz XYZ привет!"), "XYZ XYZ ПРИВЕТ!"); - UNIT_ASSERT_VALUES_EQUAL(ToUpperUTF8(TStringBuf("XYZ")), "XYZ"); + UNIT_ASSERT_VALUES_EQUAL(ToUpperUTF8(TStringBuf("XYZ")), "XYZ"); { TString s = "ПРИВЕТ!"; @@ -93,7 +93,7 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) { } Y_UNIT_TEST(TestUTF8ToWide) { - TFileInput in(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/test1.txt")); + TFileInput in(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/test1.txt")); TString text = in.ReadAll(); UNIT_ASSERT(WideToUTF8(UTF8ToWide(text)) == text); @@ -101,7 +101,7 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) { Y_UNIT_TEST(TestInvalidUTF8) { TVector<TString> testData; - TFileInput input(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/invalid_UTF8.bin")); + TFileInput input(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/invalid_UTF8.bin")); Load(&input, testData); for (const auto& text : testData) { @@ -110,7 +110,7 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) { } Y_UNIT_TEST(TestUTF8ToWideScalar) { - TFileInput in(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/test1.txt")); + TFileInput in(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/test1.txt")); TString text = in.ReadAll(); TUtf16String wtextSSE = UTF8ToWide(text); diff --git a/util/charset/wide.h b/util/charset/wide.h index 04e6928aab..fce8ed500b 100644 --- a/util/charset/wide.h +++ b/util/charset/wide.h @@ -815,10 +815,10 @@ void EscapeHtmlChars(TUtf16String& str); //! returns number of characters in range. Handle surrogate pairs as one character. inline size_t CountWideChars(const wchar16* b, const wchar16* e) { size_t count = 0; - Y_ENSURE(b <= e, TStringBuf("invalid iterators")); + Y_ENSURE(b <= e, TStringBuf("invalid iterators")); while (b < e) { b = SkipSymbol(b, e); - ++count; + ++count; } return count; } @@ -829,7 +829,7 @@ inline size_t CountWideChars(const TWtringBuf str) { //! checks whether the range is valid UTF-16 sequence inline bool IsValidUTF16(const wchar16* b, const wchar16* e) { - Y_ENSURE(b <= e, TStringBuf("invalid iterators")); + Y_ENSURE(b <= e, TStringBuf("invalid iterators")); while (b < e) { wchar32 symbol = ReadSymbolAndAdvance(b, e); if (symbol == BROKEN_RUNE) diff --git a/util/datetime/base.cpp b/util/datetime/base.cpp index 38ecc3ab96..b78def8c77 100644 --- a/util/datetime/base.cpp +++ b/util/datetime/base.cpp @@ -146,7 +146,7 @@ void Out<TInstant>(IOutputStream& os, TTypeTraits<TInstant>::TFuncParam instant) auto len = FormatDate8601(buf, sizeof(buf), instant.TimeT()); // shouldn't happen due to current implementation of FormatDate8601() and GmTimeR() - Y_ENSURE(len, TStringBuf("Out<TInstant>: year does not fit into an integer")); + Y_ENSURE(len, TStringBuf("Out<TInstant>: year does not fit into an integer")); os.Write(buf, len - 1 /* 'Z' */); WriteMicroSecondsToStream(os, instant.MicroSecondsOfSecond()); diff --git a/util/datetime/base_ut.cpp b/util/datetime/base_ut.cpp index afc3f802eb..e098ce06d5 100644 --- a/util/datetime/base_ut.cpp +++ b/util/datetime/base_ut.cpp @@ -493,8 +493,8 @@ Y_UNIT_TEST_SUITE(DateTimeTest) { } Y_UNIT_TEST(TestNoexceptConstruction) { - UNIT_ASSERT_EXCEPTION(TDuration::MilliSeconds(FromString(TStringBuf("not a number"))), yexception); - UNIT_ASSERT_EXCEPTION(TDuration::Seconds(FromString(TStringBuf("not a number"))), yexception); + UNIT_ASSERT_EXCEPTION(TDuration::MilliSeconds(FromString(TStringBuf("not a number"))), yexception); + UNIT_ASSERT_EXCEPTION(TDuration::Seconds(FromString(TStringBuf("not a number"))), yexception); } Y_UNIT_TEST(TestFromValueForTDuration) { diff --git a/util/datetime/cputimer.h b/util/datetime/cputimer.h index 7d38d5bdb3..820454f8b6 100644 --- a/util/datetime/cputimer.h +++ b/util/datetime/cputimer.h @@ -12,7 +12,7 @@ private: TStringStream Message_; public: - TTimer(const TStringBuf message = TStringBuf(" took: ")); + TTimer(const TStringBuf message = TStringBuf(" took: ")); ~TTimer(); }; diff --git a/util/datetime/parser_deprecated_ut.cpp b/util/datetime/parser_deprecated_ut.cpp index 6ad9f885b1..13383d3f18 100644 --- a/util/datetime/parser_deprecated_ut.cpp +++ b/util/datetime/parser_deprecated_ut.cpp @@ -466,53 +466,53 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTestDeprecated) { Y_UNIT_TEST(TestTInstantTryParseDeprecated) { { - const TStringBuf s = "2009-09-19 03:37:08.1+04:00"; + const TStringBuf s = "2009-09-19 03:37:08.1+04:00"; const auto i = TInstant::ParseIso8601Deprecated(s); TInstant iTry; UNIT_ASSERT(TInstant::TryParseIso8601Deprecated(s, iTry)); UNIT_ASSERT_VALUES_EQUAL(i, iTry); } { - const TStringBuf s = "2009-09aslkdjfkljasdjfl4:00"; + const TStringBuf s = "2009-09aslkdjfkljasdjfl4:00"; TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseIso8601Deprecated(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseIso8601Deprecated(s, iTry)); } { - const TStringBuf s = "Wed, 14 Oct 2009 16:55:33 GMT"; + const TStringBuf s = "Wed, 14 Oct 2009 16:55:33 GMT"; const auto i = TInstant::ParseRfc822Deprecated(s); TInstant iTry; UNIT_ASSERT(TInstant::TryParseRfc822Deprecated(s, iTry)); UNIT_ASSERT_VALUES_EQUAL(i, iTry); } { - const TStringBuf s = "Wed, alsdjflkasjdfl:55:33 GMT"; + const TStringBuf s = "Wed, alsdjflkasjdfl:55:33 GMT"; TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseRfc822Deprecated(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseRfc822Deprecated(s, iTry)); } { - const TStringBuf s = "20091014165533Z"; + const TStringBuf s = "20091014165533Z"; const auto i = TInstant::ParseX509ValidityDeprecated(s); TInstant iTry; UNIT_ASSERT(TInstant::TryParseX509Deprecated(s, iTry)); UNIT_ASSERT_VALUES_EQUAL(i, iTry); } { - const TStringBuf s = "200asdfasdf533Z"; + const TStringBuf s = "200asdfasdf533Z"; TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseX509ValidityDeprecated(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseX509Deprecated(s, iTry)); } { - const TStringBuf s = "990104074212Z"; + const TStringBuf s = "990104074212Z"; const auto i = TInstant::ParseX509ValidityDeprecated(s); TInstant iTry; UNIT_ASSERT(TInstant::TryParseX509Deprecated(s, iTry)); UNIT_ASSERT_VALUES_EQUAL(i, iTry); } { - const TStringBuf s = "9901asdf4212Z"; + const TStringBuf s = "9901asdf4212Z"; TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseX509ValidityDeprecated(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseX509Deprecated(s, iTry)); diff --git a/util/datetime/parser_ut.cpp b/util/datetime/parser_ut.cpp index 61364af997..b430bc6abf 100644 --- a/util/datetime/parser_ut.cpp +++ b/util/datetime/parser_ut.cpp @@ -516,53 +516,53 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) { Y_UNIT_TEST(TestTInstantTryParse) { { - const TStringBuf s = "2009-09-19 03:37:08.1+04:00"; + const TStringBuf s = "2009-09-19 03:37:08.1+04:00"; const auto i = TInstant::ParseIso8601(s); TInstant iTry; UNIT_ASSERT(TInstant::TryParseIso8601(s, iTry)); UNIT_ASSERT_VALUES_EQUAL(i, iTry); } { - const TStringBuf s = "2009-09aslkdjfkljasdjfl4:00"; + const TStringBuf s = "2009-09aslkdjfkljasdjfl4:00"; TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseIso8601(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseIso8601(s, iTry)); } { - const TStringBuf s = "Wed, 14 Oct 2009 16:55:33 GMT"; + const TStringBuf s = "Wed, 14 Oct 2009 16:55:33 GMT"; const auto i = TInstant::ParseRfc822(s); TInstant iTry; UNIT_ASSERT(TInstant::TryParseRfc822(s, iTry)); UNIT_ASSERT_VALUES_EQUAL(i, iTry); } { - const TStringBuf s = "Wed, alsdjflkasjdfl:55:33 GMT"; + const TStringBuf s = "Wed, alsdjflkasjdfl:55:33 GMT"; TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseRfc822(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseRfc822(s, iTry)); } { - const TStringBuf s = "20091014165533Z"; + const TStringBuf s = "20091014165533Z"; const auto i = TInstant::ParseX509Validity(s); TInstant iTry; UNIT_ASSERT(TInstant::TryParseX509(s, iTry)); UNIT_ASSERT_VALUES_EQUAL(i, iTry); } { - const TStringBuf s = "200asdfasdf533Z"; + const TStringBuf s = "200asdfasdf533Z"; TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseX509Validity(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseX509(s, iTry)); } { - const TStringBuf s = "990104074212Z"; + const TStringBuf s = "990104074212Z"; const auto i = TInstant::ParseX509Validity(s); TInstant iTry; UNIT_ASSERT(TInstant::TryParseX509(s, iTry)); UNIT_ASSERT_VALUES_EQUAL(i, iTry); } { - const TStringBuf s = "9901asdf4212Z"; + const TStringBuf s = "9901asdf4212Z"; TInstant iTry; UNIT_ASSERT_EXCEPTION(TInstant::ParseX509Validity(s), TDateTimeParseException); UNIT_ASSERT(!TInstant::TryParseX509(s, iTry)); diff --git a/util/datetime/strptime.cpp b/util/datetime/strptime.cpp index f0d4ec333e..709eb56b80 100644 --- a/util/datetime/strptime.cpp +++ b/util/datetime/strptime.cpp @@ -190,7 +190,7 @@ _strptime(const char* buf, const char* fmt, struct tm* tm, int* GMTp) if (c != '%') { if (isspace((unsigned char)c)) while (*buf != 0 && isspace((unsigned char)*buf)) - ++buf; + ++buf; else if (c != *buf++) return 0; continue; diff --git a/util/datetime/systime.cpp b/util/datetime/systime.cpp index 6ee7e8fc6e..f77464704b 100644 --- a/util/datetime/systime.cpp +++ b/util/datetime/systime.cpp @@ -113,14 +113,14 @@ struct tm* GmTimeR(const time_t* timer, struct tm* tmbuf) { tmbuf->tm_wday = (dayno + 4) % 7; // Day 0 was a thursday while (dayno >= (ui64)YEARSIZE(year)) { dayno -= YEARSIZE(year); - ++year; + ++year; } tmbuf->tm_year = year - YEAR0; tmbuf->tm_yday = dayno; tmbuf->tm_mon = 0; while (dayno >= (ui64)_ytab[LEAPYEAR(year)][tmbuf->tm_mon]) { dayno -= _ytab[LEAPYEAR(year)][tmbuf->tm_mon]; - ++tmbuf->tm_mon; + ++tmbuf->tm_mon; } tmbuf->tm_mday = dayno + 1; tmbuf->tm_isdst = 0; diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp index ffc9b09f96..e939217037 100644 --- a/util/folder/dirut.cpp +++ b/util/folder/dirut.cpp @@ -87,29 +87,29 @@ bool resolvepath(TString& folder, const TString& home) { break; } else { memmove(pp + j, pp + j + 1, (i - j - 1) * sizeof(p)); - --i; + --i; } } else if (strcmp(p, "..") == 0) { if (j == i - 1) { if (j == 1) { p = ""; } else { - --i; + --i; pp[j - 1] = ""; } break; } else { if (j == 1) { memmove(pp + j, pp + j + 1, (i - j - 1) * sizeof(p)); - --i; + --i; } else { memmove(pp + j - 1, pp + j + 1, (i - j - 1) * sizeof(p)); i -= 2; - --j; + --j; } } } else - ++j; + ++j; } char* s = newpath; @@ -144,10 +144,10 @@ static int next_dir(T*& ptr) { int c = (unsigned char)*ptr++; switch (c) { case ' ': - ++has_blank; + ++has_blank; break; case '.': - ++has_dot; + ++has_dot; break; case '/': case ':': @@ -157,17 +157,17 @@ static int next_dir(T*& ptr) { case '<': case '>': case '|': - ++has_ctrl; + ++has_ctrl; break; default: if (c == 127 || c < ' ') - ++has_ctrl; + ++has_ctrl; else - ++has_letter; + ++has_letter; } } if (*ptr) - ++ptr; + ++ptr; if (has_ctrl) return dt_error; if (has_letter) @@ -208,7 +208,7 @@ static int skip_disk(T*& ptr) { ptr += 2; } if (*ptr == '\\' || *ptr == '/') { - ++ptr; + ++ptr; result |= dk_fromroot; } } @@ -228,14 +228,14 @@ int correctpath(char* cpath, const char* path) { if (c == '/') c = '\\'; if (c == '\\') - ++counter; + ++counter; else counter = 0; if (counter <= 1) { *cptr = c; - ++cptr; + ++cptr; } - ++ptr; + ++ptr; } *cptr = 0; // replace '/' by '\' @@ -249,21 +249,21 @@ int correctpath(char* cpath, const char* path) { while (*ptr) { switch (next_dir(ptr)) { case dt_dir: - ++level; + ++level; break; case dt_empty: memmove(ptr1, ptr, strlen(ptr) + 1); ptr = ptr1; break; case dt_up: - --level; + --level; if (level >= 0) { *--ptr1 = 0; ptr1 = strrchr(cpath, '\\'); if (!ptr1) ptr1 = cpath; else - ++ptr1; + ++ptr1; memmove(ptr1, ptr, strlen(ptr) + 1); ptr = ptr1; break; diff --git a/util/folder/filelist.cpp b/util/folder/filelist.cpp index b21fcdbf20..5872a9c9c0 100644 --- a/util/folder/filelist.cpp +++ b/util/folder/filelist.cpp @@ -16,7 +16,7 @@ void TFileEntitiesList::Fill(const TString& dirname, TStringBuf prefix, TStringB size_t dirNameLength = dirname.length(); while (dirNameLength && (dirname[dirNameLength - 1] == '\\' || dirname[dirNameLength - 1] == '/')) { - --dirNameLength; + --dirNameLength; } for (auto file = dir.begin(); file != dir.end(); ++file) { diff --git a/util/folder/fts.cpp b/util/folder/fts.cpp index 0e6a6f86eb..326c37ef13 100644 --- a/util/folder/fts.cpp +++ b/util/folder/fts.cpp @@ -902,7 +902,7 @@ fts_build(FTS* sp, int type) /* GCC, you're too verbose. */ cp = nullptr; } - ++len; + ++len; maxlen = sp->fts_pathlen - len; level = cur->fts_level + 1; diff --git a/util/folder/path.cpp b/util/folder/path.cpp index bfe0c67d68..1f1f27aedc 100644 --- a/util/folder/path.cpp +++ b/util/folder/path.cpp @@ -17,7 +17,7 @@ struct TFsPath::TSplit: public TAtomicRefCount<TSplit>, public TPathSplit { void TFsPath::CheckDefined() const { if (!IsDefined()) { - ythrow TIoException() << TStringBuf("must be defined"); + ythrow TIoException() << TStringBuf("must be defined"); } } @@ -83,7 +83,7 @@ TFsPath TFsPath::RelativePath(const TFsPath& root) const { size_t cnt = 0; while (split.size() > cnt && rsplit.size() > cnt && split[cnt] == rsplit[cnt]) { - ++cnt; + ++cnt; } bool absboth = split.IsAbsolute && rsplit.IsAbsolute; if (cnt == 0 && !absboth) { diff --git a/util/folder/pathsplit.cpp b/util/folder/pathsplit.cpp index 81d439a727..cb2340bbc6 100644 --- a/util/folder/pathsplit.cpp +++ b/util/folder/pathsplit.cpp @@ -17,8 +17,8 @@ static inline size_t ToReserve(const T& t) { } void TPathSplitTraitsUnix::DoParseFirstPart(const TStringBuf part) { - if (part == TStringBuf(".")) { - push_back(TStringBuf(".")); + if (part == TStringBuf(".")) { + push_back(TStringBuf(".")); return; } @@ -46,8 +46,8 @@ void TPathSplitTraitsUnix::DoParsePart(const TStringBuf part0) { void TPathSplitTraitsWindows::DoParseFirstPart(const TStringBuf part0) { TStringBuf part(part0); - if (part == TStringBuf(".")) { - push_back(TStringBuf(".")); + if (part == TStringBuf(".")) { + push_back(TStringBuf(".")); return; } @@ -107,9 +107,9 @@ TString TPathSplitStore::DoReconstruct(const TStringBuf slash) const { } void TPathSplitStore::AppendComponent(const TStringBuf comp) { - if (!comp || comp == TStringBuf(".")) { + if (!comp || comp == TStringBuf(".")) { ; // ignore - } else if (comp == TStringBuf("..") && !empty() && back() != TStringBuf("..")) { + } else if (comp == TStringBuf("..") && !empty() && back() != TStringBuf("..")) { pop_back(); } else { // push back first .. also diff --git a/util/folder/pathsplit.h b/util/folder/pathsplit.h index d134338e35..8d893f6eac 100644 --- a/util/folder/pathsplit.h +++ b/util/folder/pathsplit.h @@ -25,7 +25,7 @@ struct TPathSplitTraitsUnix: public TPathSplitStore { static constexpr char MainPathSep = '/'; inline TString Reconstruct() const { - return DoReconstruct(TStringBuf("/")); + return DoReconstruct(TStringBuf("/")); } static constexpr bool IsPathSep(const char c) noexcept { @@ -44,7 +44,7 @@ struct TPathSplitTraitsWindows: public TPathSplitStore { static constexpr char MainPathSep = '\\'; inline TString Reconstruct() const { - return DoReconstruct(TStringBuf("\\")); + return DoReconstruct(TStringBuf("\\")); } static constexpr bool IsPathSep(char c) noexcept { diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp index 8d732fcc0c..c44e3c2224 100644 --- a/util/generic/algorithm_ut.cpp +++ b/util/generic/algorithm_ut.cpp @@ -8,10 +8,10 @@ static auto isOne = [](char c) { return c == '1'; }; Y_UNIT_TEST_SUITE(TAlgorithm) { Y_UNIT_TEST(AnyTest) { - UNIT_ASSERT(0 == AnyOf(TStringBuf("00"), isOne)); - UNIT_ASSERT(1 == AnyOf(TStringBuf("01"), isOne)); - UNIT_ASSERT(1 == AnyOf(TStringBuf("10"), isOne)); - UNIT_ASSERT(1 == AnyOf(TStringBuf("11"), isOne)); + UNIT_ASSERT(0 == AnyOf(TStringBuf("00"), isOne)); + UNIT_ASSERT(1 == AnyOf(TStringBuf("01"), isOne)); + UNIT_ASSERT(1 == AnyOf(TStringBuf("10"), isOne)); + UNIT_ASSERT(1 == AnyOf(TStringBuf("11"), isOne)); UNIT_ASSERT(0 == AnyOf(TStringBuf(), isOne)); const char array00[]{'0', '0'}; @@ -21,10 +21,10 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { } Y_UNIT_TEST(AllOfTest) { - UNIT_ASSERT(0 == AllOf(TStringBuf("00"), isOne)); - UNIT_ASSERT(0 == AllOf(TStringBuf("01"), isOne)); - UNIT_ASSERT(0 == AllOf(TStringBuf("10"), isOne)); - UNIT_ASSERT(1 == AllOf(TStringBuf("11"), isOne)); + UNIT_ASSERT(0 == AllOf(TStringBuf("00"), isOne)); + UNIT_ASSERT(0 == AllOf(TStringBuf("01"), isOne)); + UNIT_ASSERT(0 == AllOf(TStringBuf("10"), isOne)); + UNIT_ASSERT(1 == AllOf(TStringBuf("11"), isOne)); UNIT_ASSERT(1 == AllOf(TStringBuf(), isOne)); const char array01[]{'0', '1'}; @@ -34,11 +34,11 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { } Y_UNIT_TEST(CountIfTest) { - UNIT_ASSERT(3 == CountIf(TStringBuf("____1________1____1_______"), isOne)); - UNIT_ASSERT(5 == CountIf(TStringBuf("1____1________1____1_______1"), isOne)); - UNIT_ASSERT(0 == CountIf(TStringBuf("___________"), isOne)); + UNIT_ASSERT(3 == CountIf(TStringBuf("____1________1____1_______"), isOne)); + UNIT_ASSERT(5 == CountIf(TStringBuf("1____1________1____1_______1"), isOne)); + UNIT_ASSERT(0 == CountIf(TStringBuf("___________"), isOne)); UNIT_ASSERT(0 == CountIf(TStringBuf(), isOne)); - UNIT_ASSERT(1 == CountIf(TStringBuf("1"), isOne)); + UNIT_ASSERT(1 == CountIf(TStringBuf("1"), isOne)); const char array[] = "____1________1____1_______"; UNIT_ASSERT(3 == CountIf(array, isOne)); @@ -46,11 +46,11 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { Y_UNIT_TEST(CountTest) { UNIT_ASSERT(3 == Count("____1________1____1_______", '1')); - UNIT_ASSERT(3 == Count(TStringBuf("____1________1____1_______"), '1')); - UNIT_ASSERT(5 == Count(TStringBuf("1____1________1____1_______1"), '1')); - UNIT_ASSERT(0 == Count(TStringBuf("___________"), '1')); + UNIT_ASSERT(3 == Count(TStringBuf("____1________1____1_______"), '1')); + UNIT_ASSERT(5 == Count(TStringBuf("1____1________1____1_______1"), '1')); + UNIT_ASSERT(0 == Count(TStringBuf("___________"), '1')); UNIT_ASSERT(0 == Count(TStringBuf(), '1')); - UNIT_ASSERT(1 == Count(TStringBuf("1"), '1')); + UNIT_ASSERT(1 == Count(TStringBuf("1"), '1')); const char array[] = "____1________1____1_______"; UNIT_ASSERT(3 == Count(array, '1')); @@ -85,18 +85,18 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), "123", "poi", "xyz"), 1); // TString and TStringBuf - UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi")), 0); - UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi"), - TStringBuf("xyz")), + UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi")), 0); + UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi"), + TStringBuf("xyz")), 1); // TStringBuf and const char * - UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi"), 0); - UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi", "xyz"), 1); + UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi"), 0); + UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi", "xyz"), 1); // TStringBuf and TString - UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi")), 0); - UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi"), + UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi")), 0); + UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi"), TString("xyz")), 1); } @@ -151,7 +151,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { struct TVectorNoCopy: std::vector<int> { public: - TVectorNoCopy() = default; + TVectorNoCopy() = default; private: TVectorNoCopy(const TVectorNoCopy&); diff --git a/util/generic/bitops.h b/util/generic/bitops.h index 2db15fc59b..28983463a6 100644 --- a/util/generic/bitops.h +++ b/util/generic/bitops.h @@ -81,7 +81,7 @@ namespace NBitOps { value >>= 1; while (value) { value >>= 1; - ++result; + ++result; } return result; @@ -282,7 +282,7 @@ Y_FORCE_INLINE ui64 MostSignificantBit(ui64 v) { ui64 res = 0; if (v) while (v >>= 1) - ++res; + ++res; #endif return res; } @@ -301,7 +301,7 @@ Y_FORCE_INLINE ui64 LeastSignificantBit(ui64 v) { ui64 res = 0; if (v) { while (!(v & 1)) { - ++res; + ++res; v >>= 1; } } diff --git a/util/generic/bitops_ut.cpp b/util/generic/bitops_ut.cpp index d23c2b5c27..018c9bae6e 100644 --- a/util/generic/bitops_ut.cpp +++ b/util/generic/bitops_ut.cpp @@ -36,7 +36,7 @@ static T ReverseBitsSlow(T v) { for (v >>= 1; v; v >>= 1) { r <<= 1; r |= v & 1; - --s; + --s; } r <<= s; // shift when v's highest bits are zero diff --git a/util/generic/hash.h b/util/generic/hash.h index e46db21fa9..1ec3d35677 100644 --- a/util/generic/hash.h +++ b/util/generic/hash.h @@ -77,8 +77,8 @@ struct __yhashtable_iterator { : cur(n) { } /*y*/ - __yhashtable_iterator() = default; - + __yhashtable_iterator() = default; + reference operator*() const { return cur->val; } @@ -961,7 +961,7 @@ __yhashtable_iterator<V>& __yhashtable_iterator<V>::operator++() { if ((uintptr_t)cur & 1) { node** bucket = (node**)((uintptr_t)cur & ~1); while (*bucket == nullptr) - ++bucket; + ++bucket; Y_ASSERT(*bucket != nullptr); cur = (node*)((uintptr_t)*bucket & ~1); } @@ -982,7 +982,7 @@ __yhashtable_const_iterator<V>& __yhashtable_const_iterator<V>::operator++() { if ((uintptr_t)cur & 1) { node** bucket = (node**)((uintptr_t)cur & ~1); while (*bucket == nullptr) - ++bucket; + ++bucket; Y_ASSERT(*bucket != nullptr); cur = (node*)((uintptr_t)*bucket & ~1); } diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp index 0551d58770..0d986dc19b 100644 --- a/util/generic/hash_ut.cpp +++ b/util/generic/hash_ut.cpp @@ -306,7 +306,7 @@ void THashTest::TestHMMap1() { UNIT_ASSERT((*i).first == 'X'); UNIT_ASSERT((*i).second == 10); - ++i; + ++i; UNIT_ASSERT((*i).first == 'X'); UNIT_ASSERT((*i).second == 20); @@ -746,7 +746,7 @@ void THashTest::TestInvariants() { int count1 = 0; for (auto pos = set.begin(); pos != set.end(); pos++) { - ++count1; + ++count1; } UNIT_ASSERT_VALUES_EQUAL(count1, 1000); @@ -1143,7 +1143,7 @@ void THashTest::TestAt() { char key[] = {11, 12, 0, 1, 2, 11, 0}; TEST_AT_THROWN_EXCEPTION(TString, TString, char*, key, "\\x0B\\x0C"); - TEST_AT_THROWN_EXCEPTION(TString, TString, TStringBuf, TStringBuf(key, sizeof(key) - 1), "\\x0B\\x0C\\0\\1\\2\\x0B"); + TEST_AT_THROWN_EXCEPTION(TString, TString, TStringBuf, TStringBuf(key, sizeof(key) - 1), "\\x0B\\x0C\\0\\1\\2\\x0B"); #undef TEST_AT_THROWN_EXCEPTION } diff --git a/util/generic/is_in_ut.cpp b/util/generic/is_in_ut.cpp index c668bce807..ca183a9d5d 100644 --- a/util/generic/is_in_ut.cpp +++ b/util/generic/is_in_ut.cpp @@ -81,12 +81,12 @@ Y_UNIT_TEST_SUITE(TIsIn) { UNIT_ASSERT(IsIn({6}, 6)); UNIT_ASSERT(!IsIn({6}, 7)); UNIT_ASSERT(!IsIn(std::initializer_list<int>(), 6)); - UNIT_ASSERT(IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("abc"))); - UNIT_ASSERT(IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("def"))); - UNIT_ASSERT(IsIn({"abc", "def"}, TStringBuf("def"))); + UNIT_ASSERT(IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("abc"))); + UNIT_ASSERT(IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("def"))); + UNIT_ASSERT(IsIn({"abc", "def"}, TStringBuf("def"))); UNIT_ASSERT(IsIn({abc, def}, def)); // direct pointer comparison - UNIT_ASSERT(!IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("ghi"))); - UNIT_ASSERT(!IsIn({"abc", "def"}, TStringBuf("ghi"))); + UNIT_ASSERT(!IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("ghi"))); + UNIT_ASSERT(!IsIn({"abc", "def"}, TStringBuf("ghi"))); UNIT_ASSERT(!IsIn({"abc", "def"}, TString("ghi"))); const TStringBuf str = "abc////"; @@ -111,6 +111,6 @@ Y_UNIT_TEST_SUITE(TIsIn) { UNIT_ASSERT(IsIn(array, "a")); UNIT_ASSERT(IsIn(array, TString("b"))); UNIT_ASSERT(!IsIn(array, "c")); - UNIT_ASSERT(IsIn(array, TStringBuf("d"))); + UNIT_ASSERT(IsIn(array, TStringBuf("d"))); } } diff --git a/util/generic/iterator_ut.cpp b/util/generic/iterator_ut.cpp index 00be19e10e..6e7494b28c 100644 --- a/util/generic/iterator_ut.cpp +++ b/util/generic/iterator_ut.cpp @@ -52,9 +52,9 @@ Y_UNIT_TEST_SUITE(TInputRangeAdaptor) { }; Y_UNIT_TEST(TUrlPart) { - const TVector<TStringBuf> expected = {TStringBuf("yandex.ru"), TStringBuf("search?")}; + const TVector<TStringBuf> expected = {TStringBuf("yandex.ru"), TStringBuf("search?")}; auto expected_part = expected.begin(); - for (const TStringBuf& part : TUrlPart(TStringBuf("yandex.ru/search?"))) { + for (const TStringBuf& part : TUrlPart(TStringBuf("yandex.ru/search?"))) { UNIT_ASSERT_VALUES_EQUAL(part, *expected_part); ++expected_part; } diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp index 79e832b024..63f6ae574a 100644 --- a/util/generic/map_ut.cpp +++ b/util/generic/map_ut.cpp @@ -80,13 +80,13 @@ Y_UNIT_TEST_SUITE(TYMapTest) { m.insert(std::pair<const char, int>('Y', 32)); // jbuck: standard way typename mmap::iterator i = m.find('X'); // Find first match. - ++i; + ++i; UNIT_ASSERT((*i).first == 'X'); UNIT_ASSERT((*i).second == 20); - ++i; + ++i; UNIT_ASSERT((*i).first == 'Y'); UNIT_ASSERT((*i).second == 32); - ++i; + ++i; UNIT_ASSERT(i == m.end()); size_t count = m.erase('X'); diff --git a/util/generic/maybe.cpp b/util/generic/maybe.cpp index 43262934f8..6ce4627190 100644 --- a/util/generic/maybe.cpp +++ b/util/generic/maybe.cpp @@ -1,13 +1,13 @@ #include "maybe.h" -#include <util/system/type_name.h> +#include <util/system/type_name.h> -[[noreturn]] void NMaybe::TPolicyUndefinedExcept::OnEmpty(const std::type_info& valueTypeInfo) { - ythrow yexception() << "TMaybe is empty, value type: "sv << TypeName(valueTypeInfo); +[[noreturn]] void NMaybe::TPolicyUndefinedExcept::OnEmpty(const std::type_info& valueTypeInfo) { + ythrow yexception() << "TMaybe is empty, value type: "sv << TypeName(valueTypeInfo); } -[[noreturn]] void NMaybe::TPolicyUndefinedFail::OnEmpty(const std::type_info& valueTypeInfo) { - const TString typeName = TypeName(valueTypeInfo); - Y_FAIL("TMaybe is empty, value type: %s", typeName.c_str()); +[[noreturn]] void NMaybe::TPolicyUndefinedFail::OnEmpty(const std::type_info& valueTypeInfo) { + const TString typeName = TypeName(valueTypeInfo); + Y_FAIL("TMaybe is empty, value type: %s", typeName.c_str()); } template <> diff --git a/util/generic/maybe.h b/util/generic/maybe.h index 34d21aebcd..b1b1a681e5 100644 --- a/util/generic/maybe.h +++ b/util/generic/maybe.h @@ -11,11 +11,11 @@ namespace NMaybe { struct TPolicyUndefinedExcept { - [[noreturn]] static void OnEmpty(const std::type_info& valueTypeInfo); + [[noreturn]] static void OnEmpty(const std::type_info& valueTypeInfo); }; struct TPolicyUndefinedFail { - [[noreturn]] static void OnEmpty(const std::type_info& valueTypeInfo); + [[noreturn]] static void OnEmpty(const std::type_info& valueTypeInfo); }; } @@ -301,7 +301,7 @@ public: void CheckDefined() const { if (Y_UNLIKELY(!Defined())) { - Policy::OnEmpty(typeid(TValueType)); + Policy::OnEmpty(typeid(TValueType)); } } @@ -716,7 +716,7 @@ inline IOutputStream& operator<<(IOutputStream& out, const TMaybe<T, TPolicy>& m if (maybe.Defined()) { out << *maybe; } else { - out << TStringBuf("(empty maybe)"); + out << TStringBuf("(empty maybe)"); } return out; } diff --git a/util/generic/maybe_ut.cpp b/util/generic/maybe_ut.cpp index 2c1a425c5e..1213f7f9f4 100644 --- a/util/generic/maybe_ut.cpp +++ b/util/generic/maybe_ut.cpp @@ -998,9 +998,9 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(m.Defined()); UNIT_ASSERT(m->FromMaybeConstructorApplied); } - - Y_UNIT_TEST(TestOnEmptyException) { - TMaybe<TStringBuf> v; - UNIT_ASSERT_EXCEPTION_CONTAINS(v.GetRef(), yexception, "StringBuf"); - } + + Y_UNIT_TEST(TestOnEmptyException) { + TMaybe<TStringBuf> v; + UNIT_ASSERT_EXCEPTION_CONTAINS(v.GetRef(), yexception, "StringBuf"); + } } diff --git a/util/generic/reserve.h b/util/generic/reserve.h index 81ceed19dc..a4610208a4 100644 --- a/util/generic/reserve.h +++ b/util/generic/reserve.h @@ -6,6 +6,6 @@ namespace NDetail { }; } -constexpr ::NDetail::TReserveTag Reserve(size_t capacity) { +constexpr ::NDetail::TReserveTag Reserve(size_t capacity) { return ::NDetail::TReserveTag{capacity}; } diff --git a/util/generic/strbase.h b/util/generic/strbase.h index ab39fc7537..66361b9b27 100644 --- a/util/generic/strbase.h +++ b/util/generic/strbase.h @@ -107,10 +107,10 @@ public: using const_reverse_iterator = TReverseIteratorBase<const_iterator>; static constexpr size_t StrLen(const TCharType* s) noexcept { - if (Y_LIKELY(s)) { + if (Y_LIKELY(s)) { return TTraits::length(s); - } - return 0; + } + return 0; } template <class TCharTraits> @@ -172,7 +172,7 @@ public: return Ptr()[Len() - 1]; } - inline TCharType front() const noexcept { + inline TCharType front() const noexcept { Y_ASSERT(!empty()); return Ptr()[0]; } @@ -261,16 +261,16 @@ public: return s1.AsStringView() == s2.AsStringView(); } - static bool equal(const TSelf& s1, const TCharType* p) noexcept { - if (p == nullptr) { - return s1.Len() == 0; - } - + static bool equal(const TSelf& s1, const TCharType* p) noexcept { + if (p == nullptr) { + return s1.Len() == 0; + } + return s1.AsStringView() == p; } - static bool equal(const TCharType* p, const TSelf& s2) noexcept { - return equal(s2, p); + static bool equal(const TCharType* p, const TSelf& s2) noexcept { + return equal(s2, p); } static bool equal(const TStringView s1, const TStringView s2) noexcept { diff --git a/util/generic/strbuf_ut.cpp b/util/generic/strbuf_ut.cpp index 69cde785af..6daf61a7cf 100644 --- a/util/generic/strbuf_ut.cpp +++ b/util/generic/strbuf_ut.cpp @@ -11,7 +11,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT_EQUAL(*str.data(), 'q'); UNIT_ASSERT_EQUAL(str.size(), 6); - TStringBuf str1("qwe\0rty"sv); + TStringBuf str1("qwe\0rty"sv); TStringBuf str2(str1.data()); UNIT_ASSERT_VALUES_UNEQUAL(str1, str2); UNIT_ASSERT_VALUES_EQUAL(str1.size(), 7); @@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestConstExpr) { static constexpr TStringBuf str1("qwe\0rty", 7); static constexpr TStringBuf str2(str1.data(), str1.size()); - static constexpr TStringBuf str3 = "qwe\0rty"sv; + static constexpr TStringBuf str3 = "qwe\0rty"sv; UNIT_ASSERT_VALUES_EQUAL(str1.size(), 7); @@ -52,8 +52,8 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestAfter) { TStringBuf str("qwerty"); - UNIT_ASSERT_VALUES_EQUAL(str.After('w'), TStringBuf("erty")); - UNIT_ASSERT_VALUES_EQUAL(str.After('x'), TStringBuf("qwerty")); + UNIT_ASSERT_VALUES_EQUAL(str.After('w'), TStringBuf("erty")); + UNIT_ASSERT_VALUES_EQUAL(str.After('x'), TStringBuf("qwerty")); UNIT_ASSERT_VALUES_EQUAL(str.After('y'), TStringBuf()); UNIT_ASSERT_STRINGS_EQUAL(str.After('='), str); @@ -65,9 +65,9 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestBefore) { TStringBuf str("qwerty"); - UNIT_ASSERT_VALUES_EQUAL(str.Before('w'), TStringBuf("q")); - UNIT_ASSERT_VALUES_EQUAL(str.Before('x'), TStringBuf("qwerty")); - UNIT_ASSERT_VALUES_EQUAL(str.Before('y'), TStringBuf("qwert")); + UNIT_ASSERT_VALUES_EQUAL(str.Before('w'), TStringBuf("q")); + UNIT_ASSERT_VALUES_EQUAL(str.Before('x'), TStringBuf("qwerty")); + UNIT_ASSERT_VALUES_EQUAL(str.Before('y'), TStringBuf("qwert")); UNIT_ASSERT_VALUES_EQUAL(str.Before('q'), TStringBuf()); } @@ -137,7 +137,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestEmpty) { UNIT_ASSERT(TStringBuf().empty()); - UNIT_ASSERT(!TStringBuf("q").empty()); + UNIT_ASSERT(!TStringBuf("q").empty()); } Y_UNIT_TEST(TestShift) { @@ -149,10 +149,10 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT(str.empty()); str = qw; - UNIT_ASSERT_EQUAL(str.SubStr(2), TStringBuf("erty")); + UNIT_ASSERT_EQUAL(str.SubStr(2), TStringBuf("erty")); UNIT_ASSERT_EQUAL(str.Skip(3), qw.SubStr(3)); str.Chop(1); - UNIT_ASSERT_EQUAL(str, TStringBuf("rt")); + UNIT_ASSERT_EQUAL(str, TStringBuf("rt")); } Y_UNIT_TEST(TestSplit) { @@ -161,19 +161,19 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { rt = qw; lt = rt.NextTok('r'); - UNIT_ASSERT_EQUAL(lt, TStringBuf("qwe")); - UNIT_ASSERT_EQUAL(rt, TStringBuf("ty")); + UNIT_ASSERT_EQUAL(lt, TStringBuf("qwe")); + UNIT_ASSERT_EQUAL(rt, TStringBuf("ty")); lt = qw; rt = lt.SplitOff('r'); - UNIT_ASSERT_EQUAL(lt, TStringBuf("qwe")); - UNIT_ASSERT_EQUAL(rt, TStringBuf("ty")); + UNIT_ASSERT_EQUAL(lt, TStringBuf("qwe")); + UNIT_ASSERT_EQUAL(rt, TStringBuf("ty")); rt = qw; lt = rt.NextTok('r'); TStringBuf ty = rt.NextTok('r'); // no 'r' in "ty" UNIT_ASSERT_EQUAL(rt.size(), 0); - UNIT_ASSERT_EQUAL(ty, TStringBuf("ty")); + UNIT_ASSERT_EQUAL(ty, TStringBuf("ty")); } Y_UNIT_TEST(TestNextTok) { @@ -187,19 +187,19 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestNextStringTok) { TStringBuf buf1("a@@b@@c"); - UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("a")); - UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("b")); - UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("c")); + UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("a")); + UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("b")); + UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("c")); UNIT_ASSERT_EQUAL(buf1, TStringBuf()); TStringBuf buf2("a@@b@@c"); - UNIT_ASSERT_EQUAL(buf2.RNextTok("@@"), TStringBuf("c")); - UNIT_ASSERT_EQUAL(buf2.RNextTok("@@"), TStringBuf("b")); - UNIT_ASSERT_EQUAL(buf2.RNextTok("@@"), TStringBuf("a")); + UNIT_ASSERT_EQUAL(buf2.RNextTok("@@"), TStringBuf("c")); + UNIT_ASSERT_EQUAL(buf2.RNextTok("@@"), TStringBuf("b")); + UNIT_ASSERT_EQUAL(buf2.RNextTok("@@"), TStringBuf("a")); UNIT_ASSERT_EQUAL(buf2, TStringBuf()); TStringBuf buf3("a@@b@@c"); - UNIT_ASSERT_EQUAL(buf3.RNextTok("@@@"), TStringBuf("a@@b@@c")); + UNIT_ASSERT_EQUAL(buf3.RNextTok("@@@"), TStringBuf("a@@b@@c")); UNIT_ASSERT_EQUAL(buf3, TStringBuf()); } @@ -223,7 +223,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { } Y_UNIT_TEST(TestRFind) { - TStringBuf buf1 = "123123456"; + TStringBuf buf1 = "123123456"; UNIT_ASSERT_EQUAL(buf1.rfind('3'), 5); UNIT_ASSERT_EQUAL(buf1.rfind('4'), 6); UNIT_ASSERT_EQUAL(buf1.rfind('7'), TStringBuf::npos); @@ -242,11 +242,11 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestRNextTok) { TStringBuf buf1("a.b.c"); - UNIT_ASSERT_EQUAL(buf1.RNextTok('.'), TStringBuf("c")); - UNIT_ASSERT_EQUAL(buf1, TStringBuf("a.b")); + UNIT_ASSERT_EQUAL(buf1.RNextTok('.'), TStringBuf("c")); + UNIT_ASSERT_EQUAL(buf1, TStringBuf("a.b")); TStringBuf buf2("a"); - UNIT_ASSERT_EQUAL(buf2.RNextTok('.'), TStringBuf("a")); + UNIT_ASSERT_EQUAL(buf2.RNextTok('.'), TStringBuf("a")); UNIT_ASSERT_EQUAL(buf2, TStringBuf()); TStringBuf buf3("ab cd ef"), tok; @@ -258,12 +258,12 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestRSplitOff) { TStringBuf buf1("a.b.c"); - UNIT_ASSERT_EQUAL(buf1.RSplitOff('.'), TStringBuf("a.b")); - UNIT_ASSERT_EQUAL(buf1, TStringBuf("c")); + UNIT_ASSERT_EQUAL(buf1.RSplitOff('.'), TStringBuf("a.b")); + UNIT_ASSERT_EQUAL(buf1, TStringBuf("c")); TStringBuf buf2("a"); UNIT_ASSERT_EQUAL(buf2.RSplitOff('.'), TStringBuf()); - UNIT_ASSERT_EQUAL(buf2, TStringBuf("a")); + UNIT_ASSERT_EQUAL(buf2, TStringBuf("a")); } Y_UNIT_TEST(TestCBeginCEnd) { @@ -352,7 +352,7 @@ Y_UNIT_TEST_SUITE(TWtrBufTest) { Y_UNIT_TEST(TestConstExpr) { static constexpr TWtringBuf str1(u"qwe\0rty", 7); static constexpr TWtringBuf str2(str1.data(), str1.size()); - static constexpr TWtringBuf str3 = u"qwe\0rty"sv; + static constexpr TWtringBuf str3 = u"qwe\0rty"sv; UNIT_ASSERT_VALUES_EQUAL(str1.size(), 7); diff --git a/util/generic/string.h b/util/generic/string.h index 8cd8aa6917..b867f9a9d2 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -205,7 +205,7 @@ protected: return {new TStdStr(std::forward<A>(a)...), typename TStorage::TNoIncrement()}; } - static TStorage Construct() noexcept { + static TStorage Construct() noexcept { return TStdStr::NullStr(); } @@ -372,7 +372,7 @@ public: } // ~~~ Constructor ~~~ : FAMILY0(,TBasicString) - TBasicString() noexcept + TBasicString() noexcept #ifndef TSTRING_IS_STD_STRING : S_(Construct()) #endif diff --git a/util/generic/string_transparent_hash_ut.cpp b/util/generic/string_transparent_hash_ut.cpp index b87fa2843e..10c782e574 100644 --- a/util/generic/string_transparent_hash_ut.cpp +++ b/util/generic/string_transparent_hash_ut.cpp @@ -15,5 +15,5 @@ Y_UNIT_TEST_SUITE(StringHashFunctorTests) { // If either `THash` or `TEqualTo` is not transparent compilation will fail. UNIT_ASSERT_UNEQUAL(s.find(TStringBuf("foo")), s.end()); UNIT_ASSERT_EQUAL(s.find(TStringBuf("bar")), s.end()); - } + } } diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp index ac82e9091d..e4fbd69c79 100644 --- a/util/generic/string_ut.cpp +++ b/util/generic/string_ut.cpp @@ -724,7 +724,7 @@ protected: class TStringTest: public TTestBase, private TStringTestImpl<TString, TTestData<char>> { public: UNIT_TEST_SUITE(TStringTest); - UNIT_TEST(TestMaxSize); + UNIT_TEST(TestMaxSize); UNIT_TEST(TestConstructors); UNIT_TEST(TestReplace); #ifndef TSTRING_IS_STD_STRING diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h index 44bb10bdeb..4bd0e376c1 100644 --- a/util/generic/string_ut.h +++ b/util/generic/string_ut.h @@ -517,13 +517,13 @@ protected: TTestData Data; public: - void TestMaxSize() { + void TestMaxSize() { const size_t badMaxVal = TStringType{}.max_size() + 1; - - TStringType s; - UNIT_CHECK_GENERATED_EXCEPTION(s.reserve(badMaxVal), std::length_error); - } - + + TStringType s; + UNIT_CHECK_GENERATED_EXCEPTION(s.reserve(badMaxVal), std::length_error); + } + void TestConstructors() { TStringType s0(nullptr); UNIT_ASSERT(s0.size() == 0); diff --git a/util/generic/typelist.h b/util/generic/typelist.h index 5ce26ab97c..19e90159cd 100644 --- a/util/generic/typelist.h +++ b/util/generic/typelist.h @@ -78,12 +78,12 @@ namespace NTL { template <bool isSigned, class T, class TS, class TU> struct TTypeSelectorBase { using TSignedInts = typename TConcat<TTypeList<T>, TS>::type; - using TUnsignedInts = TU; + using TUnsignedInts = TU; }; template <class T, class TS, class TU> struct TTypeSelectorBase<false, T, TS, TU> { - using TSignedInts = TS; + using TSignedInts = TS; using TUnsignedInts = typename TConcat<TTypeList<T>, TU>::type; }; @@ -91,8 +91,8 @@ namespace NTL { struct TTypeSelector: public TTypeSelectorBase<((T)(-1) < 0), T, TS, TU> { }; - using T1 = TTypeSelector<char, TCommonSignedInts, TCommonUnsignedInts>; - using T2 = TTypeSelector<wchar_t, T1::TSignedInts, T1::TUnsignedInts>; + using T1 = TTypeSelector<char, TCommonSignedInts, TCommonUnsignedInts>; + using T2 = TTypeSelector<wchar_t, T1::TSignedInts, T1::TUnsignedInts>; } using TSignedInts = NTL::T2::TSignedInts; diff --git a/util/generic/vector_ut.cpp b/util/generic/vector_ut.cpp index 0f6b4037a0..ce5e00cd83 100644 --- a/util/generic/vector_ut.cpp +++ b/util/generic/vector_ut.cpp @@ -505,7 +505,7 @@ private: template <class TOther> struct rebind { - using other = TDebugAlloc<TOther>; + using other = TDebugAlloc<TOther>; }; }; diff --git a/util/generic/xrange_ut.cpp b/util/generic/xrange_ut.cpp index 8106da03e7..a0c0da7121 100644 --- a/util/generic/xrange_ut.cpp +++ b/util/generic/xrange_ut.cpp @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(XRange) { size_t last = 0; for (auto i : xrange(begin, end)) { - ++count; + ++count; sum += i; last = i; if (!firstInited) { diff --git a/util/generic/yexception.cpp b/util/generic/yexception.cpp index 2ce6c4369d..9744e70e87 100644 --- a/util/generic/yexception.cpp +++ b/util/generic/yexception.cpp @@ -23,7 +23,7 @@ TString CurrentExceptionMessage() { const TBackTrace* bt = e.BackTrace(); if (bt) { - return TString::Join(bt->PrintToString(), TStringBuf("\n"), FormatExc(e)); + return TString::Join(bt->PrintToString(), TStringBuf("\n"), FormatExc(e)); } return FormatExc(e); @@ -70,9 +70,9 @@ std::string CurrentExceptionTypeName() { void TSystemError::Init() { yexception& exc = *this; - exc << TStringBuf("("); + exc << TStringBuf("("); exc << TStringBuf(LastSystemErrorText(Status_)); - exc << TStringBuf(") "); + exc << TStringBuf(") "); } NPrivateException::yexception::yexception() { diff --git a/util/generic/yexception.h b/util/generic/yexception.h index b0c604e8c4..7662c1b639 100644 --- a/util/generic/yexception.h +++ b/util/generic/yexception.h @@ -75,7 +75,7 @@ namespace NPrivateException { template <class T> static inline T&& operator+(const TSourceLocation& sl, T&& t) { - return std::forward<T>(t << sl << TStringBuf(": ")); + return std::forward<T>(t << sl << TStringBuf(": ")); } } @@ -180,7 +180,7 @@ TString FormatExc(const std::exception& exception); if (Y_UNLIKELY(!(CONDITION))) { \ ythrow THROW_EXPRESSION; \ } \ - } while (false) + } while (false) /// @def Y_ENSURE_SIMPLE /// This macro works like the Y_ENSURE, but requires the second argument to be a constant string view. @@ -194,10 +194,10 @@ TString FormatExc(const std::exception& exception); } \ } while (false) -#define Y_ENSURE_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYException) +#define Y_ENSURE_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYException) #define Y_ENSURE_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, yexception() << MESSAGE) -#define Y_ENSURE_BT_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYExceptionWithBacktrace) +#define Y_ENSURE_BT_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYExceptionWithBacktrace) #define Y_ENSURE_BT_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, TWithBackTrace<yexception>() << MESSAGE) /** diff --git a/util/generic/yexception_ut.cpp b/util/generic/yexception_ut.cpp index cb3e29fed8..0e113cdd45 100644 --- a/util/generic/yexception_ut.cpp +++ b/util/generic/yexception_ut.cpp @@ -29,9 +29,9 @@ static void CallbackFun(int i) { static IOutputStream* OUTS = nullptr; -namespace NOuter::NInner { - void Compare10And20() { - Y_ENSURE(10 > 20); +namespace NOuter::NInner { + void Compare10And20() { + Y_ENSURE(10 > 20); } } diff --git a/util/generic/ymath.h b/util/generic/ymath.h index 9ff9ae2abe..067f091a32 100644 --- a/util/generic/ymath.h +++ b/util/generic/ymath.h @@ -56,14 +56,14 @@ static constexpr T Sqr(const T t) noexcept { return t * t; } -inline double Sigmoid(double x) { - return 1.0 / (1.0 + std::exp(-x)); -} - -inline float Sigmoid(float x) { - return 1.0f / (1.0f + std::exp(-x)); -} - +inline double Sigmoid(double x) { + return 1.0 / (1.0 + std::exp(-x)); +} + +inline float Sigmoid(float x) { + return 1.0f / (1.0f + std::exp(-x)); +} + static inline bool IsFinite(double f) { #if defined(isfinite) return isfinite(f); diff --git a/util/generic/ymath_ut.cpp b/util/generic/ymath_ut.cpp index 29190b55eb..86294e9e1b 100644 --- a/util/generic/ymath_ut.cpp +++ b/util/generic/ymath_ut.cpp @@ -33,7 +33,7 @@ class TMathTest: public TTestBase { UNIT_TEST(TestIsValidFloat); UNIT_TEST(TestAbs); UNIT_TEST(TestPower); - UNIT_TEST(TestSigmoid); + UNIT_TEST(TestSigmoid); UNIT_TEST(TestCeilDiv); UNIT_TEST_SUITE_END(); @@ -44,7 +44,7 @@ private: void TestLogGamma(); void TestAbs(); void TestPower(); - void TestSigmoid(); + void TestSigmoid(); void TestCeilDiv(); inline void TestIsValidFloat() { @@ -181,16 +181,16 @@ void TMathTest::TestPower() { UNIT_ASSERT_DOUBLES_EQUAL(Power(0.0, 0), 1.0, 1e-9); UNIT_ASSERT_DOUBLES_EQUAL(Power(0.1, 3), 1e-3, 1e-9); } - -void TMathTest::TestSigmoid() { - UNIT_ASSERT_EQUAL(Sigmoid(0.f), 0.5f); - UNIT_ASSERT_EQUAL(Sigmoid(-5000.f), 0.0f); - UNIT_ASSERT_EQUAL(Sigmoid(5000.f), 1.0f); - - UNIT_ASSERT_EQUAL(Sigmoid(0.), 0.5); - UNIT_ASSERT_EQUAL(Sigmoid(-5000.), 0.0); - UNIT_ASSERT_EQUAL(Sigmoid(5000.), 1.0); -} + +void TMathTest::TestSigmoid() { + UNIT_ASSERT_EQUAL(Sigmoid(0.f), 0.5f); + UNIT_ASSERT_EQUAL(Sigmoid(-5000.f), 0.0f); + UNIT_ASSERT_EQUAL(Sigmoid(5000.f), 1.0f); + + UNIT_ASSERT_EQUAL(Sigmoid(0.), 0.5); + UNIT_ASSERT_EQUAL(Sigmoid(-5000.), 0.0); + UNIT_ASSERT_EQUAL(Sigmoid(5000.), 1.0); +} void TMathTest::TestCeilDiv() { UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui8>(2, 3), 1); diff --git a/util/memory/blob.cpp b/util/memory/blob.cpp index 91da5cadca..d0e9b6e85c 100644 --- a/util/memory/blob.cpp +++ b/util/memory/blob.cpp @@ -109,7 +109,7 @@ public: : Map_(map) , Mode_(mode) { - Y_ENSURE(Map_.IsOpen(), TStringBuf("memory map not open")); + Y_ENSURE(Map_.IsOpen(), TStringBuf("memory map not open")); Map_.Map(offset, len); @@ -122,7 +122,7 @@ public: } } - ~TMappedBlobBase() override { + ~TMappedBlobBase() override { if (Mode_ == EMappingMode::Locked && Length()) { UnlockMemory(Data(), Length()); } diff --git a/util/network/endpoint.cpp b/util/network/endpoint.cpp index 9acdd06940..d6b8aa6035 100644 --- a/util/network/endpoint.cpp +++ b/util/network/endpoint.cpp @@ -7,7 +7,7 @@ TEndpoint::TEndpoint(const TEndpoint::TAddrRef& addr) const sockaddr* sa = Addr_->Addr(); if (sa->sa_family != AF_INET && sa->sa_family != AF_INET6 && sa->sa_family != AF_UNIX) { - ythrow yexception() << TStringBuf("endpoint can contain only ipv4, ipv6 or unix address"); + ythrow yexception() << TStringBuf("endpoint can contain only ipv4, ipv6 or unix address"); } } diff --git a/util/network/endpoint_ut.cpp b/util/network/endpoint_ut.cpp index d5e40dd6e1..1adcf95148 100644 --- a/util/network/endpoint_ut.cpp +++ b/util/network/endpoint_ut.cpp @@ -53,8 +53,8 @@ Y_UNIT_TEST_SUITE(TEndpointTest) { TEndpoint ep3(new NAddr::TAddrInfo(&*na3.Begin())); UNIT_ASSERT(ep3.IsIpV6()); - UNIT_ASSERT(ep3.IpToString().StartsWith(TStringBuf("2a02:6b8:0:1410:"))); - UNIT_ASSERT(ep3.IpToString().EndsWith(TStringBuf(":5f6c:f3c2"))); + UNIT_ASSERT(ep3.IpToString().StartsWith(TStringBuf("2a02:6b8:0:1410:"))); + UNIT_ASSERT(ep3.IpToString().EndsWith(TStringBuf(":5f6c:f3c2"))); UNIT_ASSERT_VALUES_EQUAL(54321, ep3.Port()); TNetworkAddress na4("2a02:6b8:0:1410:0::5f6c:f3c2", 1); diff --git a/util/network/init.h b/util/network/init.h index 08a79c0fca..ea7e2898d7 100644 --- a/util/network/init.h +++ b/util/network/init.h @@ -18,7 +18,7 @@ #include <netinet/tcp.h> #include <arpa/inet.h> -using SOCKET = int; +using SOCKET = int; #define closesocket(s) close(s) #define SOCKET_ERROR -1 @@ -30,7 +30,7 @@ using SOCKET = int; #include <winsock2.h> #include <ws2tcpip.h> -using nfds_t = ULONG; +using nfds_t = ULONG; #undef Yield diff --git a/util/network/socket.cpp b/util/network/socket.cpp index 4f6e804346..c392d20dd3 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -163,7 +163,7 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept { int error = WSAGetLastError(); if (error == WSAEINVAL || error == WSAENOTSOCK) { fd->revents = POLLNVAL; - ++checked_sockets; + ++checked_sockets; } else { errno = EIO; return -1; @@ -188,7 +188,7 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept { if (FD_ISSET(fd->fd, &writefds)) { fd->revents |= POLLOUT; } - ++checked_sockets; + ++checked_sockets; } } diff --git a/util/network/socket_ut.cpp b/util/network/socket_ut.cpp index 6b20e11f70..78bc5b12e8 100644 --- a/util/network/socket_ut.cpp +++ b/util/network/socket_ut.cpp @@ -46,7 +46,7 @@ void TSockTest::TestSock() { TSocket s(addr); TSocketOutput so(s); TSocketInput si(s); - const TStringBuf req = "GET / HTTP/1.1\r\nHost: yandex.ru\r\n\r\n"; + const TStringBuf req = "GET / HTTP/1.1\r\nHost: yandex.ru\r\n\r\n"; so.Write(req.data(), req.size()); diff --git a/util/random/entropy.cpp b/util/random/entropy.cpp index 3617edb83d..9548784b6a 100644 --- a/util/random/entropy.cpp +++ b/util/random/entropy.cpp @@ -107,7 +107,7 @@ namespace { using TRnd = TMersenne<TKey>; public: - inline explicit TMersenneInput(const TBuffer& rnd) + inline explicit TMersenneInput(const TBuffer& rnd) : Rnd_((const TKey*)rnd.Data(), rnd.Size() / sizeof(TKey)) { } @@ -136,7 +136,7 @@ namespace { class TEntropyPoolStream: public IInputStream { public: - inline explicit TEntropyPoolStream(const TBuffer& buffer) + inline explicit TEntropyPoolStream(const TBuffer& buffer) : Mi_(buffer) , Bi_(&Mi_, 8192) { diff --git a/util/stream/aligned_ut.cpp b/util/stream/aligned_ut.cpp index e980d05cf7..890dfa7d8f 100644 --- a/util/stream/aligned_ut.cpp +++ b/util/stream/aligned_ut.cpp @@ -16,7 +16,7 @@ protected: } *static_cast<unsigned char*>(buf) = static_cast<unsigned char>(Pos_); - ++Pos_; + ++Pos_; return 1; } @@ -25,7 +25,7 @@ protected: return 0; } - ++Pos_; + ++Pos_; return 1; } diff --git a/util/stream/format.h b/util/stream/format.h index b033208a1b..e3cd64cc57 100644 --- a/util/stream/format.h +++ b/util/stream/format.h @@ -118,9 +118,9 @@ namespace NFormatPrivate { if (value.Flags & HF_ADDX) { if (Base == 16) { - stream << TStringBuf("0x"); + stream << TStringBuf("0x"); } else if (Base == 2) { - stream << TStringBuf("0b"); + stream << TStringBuf("0b"); } } @@ -329,7 +329,7 @@ static constexpr ::NFormatPrivate::TBaseNumber<T, 2> SBin(const T& value, const * * Example usage: * @code - * stream << HexText(TStringBuf("abcи")); // Will output "61 62 63 D0 B8" + * stream << HexText(TStringBuf("abcи")); // Will output "61 62 63 D0 B8" * stream << HexText(TWtringBuf(u"abcи")); // Will output "0061 0062 0063 0438" * @endcode * @@ -348,7 +348,7 @@ static inline ::NFormatPrivate::TBaseText<TChar, 16> HexText(const TBasicStringB * * Example usage: * @code - * stream << BinText(TStringBuf("aaa")); // Will output "01100001 01100001 01100001" + * stream << BinText(TStringBuf("aaa")); // Will output "01100001 01100001 01100001" * @endcode * * @param value String to output. diff --git a/util/stream/format_ut.cpp b/util/stream/format_ut.cpp index 43245aeb48..9c1e7c7f9d 100644 --- a/util/stream/format_ut.cpp +++ b/util/stream/format_ut.cpp @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) { Y_UNIT_TEST(TestHexText) { { TStringStream ss; - ss << HexText(TStringBuf("abcи")); + ss << HexText(TStringBuf("abcи")); UNIT_ASSERT_VALUES_EQUAL("61 62 63 D0 B8", ss.Str()); } { @@ -76,9 +76,9 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) { } Y_UNIT_TEST(TestBinText) { - UNIT_ASSERT_VALUES_EQUAL(ToString(BinText(TStringBuf("\1"))), "00000001"); - UNIT_ASSERT_VALUES_EQUAL(ToString(BinText(TStringBuf("\1\1"))), "00000001 00000001"); - UNIT_ASSERT_VALUES_EQUAL(ToString(BinText(TStringBuf("aaa"))), "01100001 01100001 01100001"); + UNIT_ASSERT_VALUES_EQUAL(ToString(BinText(TStringBuf("\1"))), "00000001"); + UNIT_ASSERT_VALUES_EQUAL(ToString(BinText(TStringBuf("\1\1"))), "00000001 00000001"); + UNIT_ASSERT_VALUES_EQUAL(ToString(BinText(TStringBuf("aaa"))), "01100001 01100001 01100001"); } Y_UNIT_TEST(TestPrec) { diff --git a/util/stream/hex.cpp b/util/stream/hex.cpp index 1c05330504..dafcefebf7 100644 --- a/util/stream/hex.cpp +++ b/util/stream/hex.cpp @@ -16,7 +16,7 @@ void HexEncode(const void* in, size_t len, IOutputStream& out) { } void HexDecode(const void* in, size_t len, IOutputStream& out) { - Y_ENSURE(!(len & 1), TStringBuf("Odd buffer length passed to HexDecode")); + Y_ENSURE(!(len & 1), TStringBuf("Odd buffer length passed to HexDecode")); static const size_t NUM_OF_BYTES = 32; char buffer[NUM_OF_BYTES]; diff --git a/util/stream/input.cpp b/util/stream/input.cpp index 6e8170f2f9..6949bac9bc 100644 --- a/util/stream/input.cpp +++ b/util/stream/input.cpp @@ -28,7 +28,7 @@ size_t IInputStream::DoReadTo(TString& st, char to) { size_t result = 0; do { - ++result; + ++result; if (ch == to) { break; diff --git a/util/stream/mem.cpp b/util/stream/mem.cpp index 22a3339e27..4f2b73082d 100644 --- a/util/stream/mem.cpp +++ b/util/stream/mem.cpp @@ -39,7 +39,7 @@ void TMemoryInput::DoUndo(size_t len) { TMemoryOutput::~TMemoryOutput() = default; size_t TMemoryOutput::DoNext(void** ptr) { - Y_ENSURE(Buf_ < End_, TStringBuf("memory output stream exhausted")); + Y_ENSURE(Buf_ < End_, TStringBuf("memory output stream exhausted")); *ptr = Buf_; size_t bufferSize = End_ - Buf_; Buf_ = End_; @@ -53,13 +53,13 @@ void TMemoryOutput::DoUndo(size_t len) { void TMemoryOutput::DoWrite(const void* buf, size_t len) { char* end = Buf_ + len; - Y_ENSURE(end <= End_, TStringBuf("memory output stream exhausted")); + Y_ENSURE(end <= End_, TStringBuf("memory output stream exhausted")); memcpy(Buf_, buf, len); Buf_ = end; } void TMemoryOutput::DoWriteC(char c) { - Y_ENSURE(Buf_ < End_, TStringBuf("memory output stream exhausted")); + Y_ENSURE(Buf_ < End_, TStringBuf("memory output stream exhausted")); *Buf_++ = c; } diff --git a/util/stream/output.cpp b/util/stream/output.cpp index db81b81b70..a1992f6cf6 100644 --- a/util/stream/output.cpp +++ b/util/stream/output.cpp @@ -240,7 +240,7 @@ using TNullPtr = decltype(nullptr); template <> void Out<TNullPtr>(IOutputStream& o, TTypeTraits<TNullPtr>::TFuncParam) { - o << TStringBuf("nullptr"); + o << TStringBuf("nullptr"); } #if defined(_android_) diff --git a/util/stream/tokenizer_ut.cpp b/util/stream/tokenizer_ut.cpp index afc566da86..37b30d8e5f 100644 --- a/util/stream/tokenizer_ut.cpp +++ b/util/stream/tokenizer_ut.cpp @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TStreamTokenizerTests) { Y_UNIT_TEST(LastTokenendDoesntSatisfyPredicateTest) { const char data[] = "abc\ndef\nxxxxxx"; const auto dataSize = Y_ARRAY_SIZE(data) - 1; - const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")}; + const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")}; const auto tokensSize = Y_ARRAY_SIZE(tokens); auto&& input = TMemoryInput{data, dataSize}; auto&& tokenizer = TStreamTokenizer<TEol>{&input}; @@ -58,7 +58,7 @@ Y_UNIT_TEST_SUITE(TStreamTokenizerTests) { Y_UNIT_TEST(FirstTokenIsEmptyTest) { const char data[] = "\ndef\nxxxxxx"; const auto dataSize = Y_ARRAY_SIZE(data) - 1; - const TStringBuf tokens[] = {TStringBuf(), TStringBuf("def"), TStringBuf("xxxxxx")}; + const TStringBuf tokens[] = {TStringBuf(), TStringBuf("def"), TStringBuf("xxxxxx")}; const auto tokensSize = Y_ARRAY_SIZE(tokens); auto&& input = TMemoryInput{data, dataSize}; auto&& tokenizer = TStreamTokenizer<TEol>{&input}; @@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(TStreamTokenizerTests) { Y_UNIT_TEST(SimpleTest) { const char data[] = "qwerty\n1234567890\n"; const auto dataSize = Y_ARRAY_SIZE(data) - 1; - const TStringBuf tokens[] = {TStringBuf("qwerty"), TStringBuf("1234567890")}; + const TStringBuf tokens[] = {TStringBuf("qwerty"), TStringBuf("1234567890")}; const auto tokensSize = Y_ARRAY_SIZE(tokens); auto&& input = TMemoryInput{data, dataSize}; auto&& tokenizer = TStreamTokenizer<TEol>{&input}; @@ -115,7 +115,7 @@ Y_UNIT_TEST_SUITE(TStreamTokenizerTests) { const char data[] = "abc|def|xxxxxx"; const auto dataSize = Y_ARRAY_SIZE(data) - 1; - const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")}; + const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")}; const auto tokensSize = Y_ARRAY_SIZE(tokens); auto&& input = TMemoryInput{data, dataSize}; auto&& tokenizer = TStreamTokenizer<TIsVerticalBar>{&input}; @@ -139,8 +139,8 @@ Y_UNIT_TEST_SUITE(TStreamTokenizerTests) { const char data[] = "abc|def|xxxxxx,abc|def|xxxxxx"; const auto dataSize = Y_ARRAY_SIZE(data) - 1; - const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx"), - TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")}; + const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx"), + TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")}; const auto tokensSize = Y_ARRAY_SIZE(tokens); auto&& input = TMemoryInput{data, dataSize}; auto&& tokenizer = TStreamTokenizer<TIsVerticalBar>{&input}; @@ -199,7 +199,7 @@ Y_UNIT_TEST_SUITE(TStreamTokenizerTests) { Y_UNIT_TEST(FirstTokenHasSizeOfTheBufferTest) { const char data[] = "xxxxx\nxx"; const auto dataSize = Y_ARRAY_SIZE(data) - 1; - const TStringBuf tokens[] = {TStringBuf("xxxxx"), TStringBuf("xx")}; + const TStringBuf tokens[] = {TStringBuf("xxxxx"), TStringBuf("xx")}; const auto tokensSize = Y_ARRAY_SIZE(tokens); auto&& input = TMemoryInput{data, dataSize}; auto&& tokenizer = TStreamTokenizer<TEol>{&input, TEol{}, tokens[0].size()}; @@ -231,7 +231,7 @@ Y_UNIT_TEST_SUITE(TStreamTokenizerTests) { Y_UNIT_TEST(BufferSizeInitialSizeSmallerThanTokenTest) { const char data[] = "xxxxx\nxx"; const auto dataSize = Y_ARRAY_SIZE(data) - 1; - const TStringBuf tokens[] = {TStringBuf("xxxxx"), TStringBuf("xx")}; + const TStringBuf tokens[] = {TStringBuf("xxxxx"), TStringBuf("xx")}; const auto tokensSize = Y_ARRAY_SIZE(tokens); auto&& input = TMemoryInput{data, dataSize}; auto&& tokenizer = TStreamTokenizer<TEol>{&input, TEol{}, 1}; @@ -248,7 +248,7 @@ Y_UNIT_TEST_SUITE(TStreamTokenizerTests) { Y_UNIT_TEST(RangeBasedForTest) { const char data[] = "abc\ndef\nxxxxxx"; const auto dataSize = Y_ARRAY_SIZE(data) - 1; - const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")}; + const TStringBuf tokens[] = {TStringBuf("abc"), TStringBuf("def"), TStringBuf("xxxxxx")}; const auto tokensSize = Y_ARRAY_SIZE(tokens); auto&& input = TMemoryInput{data, dataSize}; auto&& tokenizer = TStreamTokenizer<TEol>{&input}; diff --git a/util/stream/zlib_ut.cpp b/util/stream/zlib_ut.cpp index 2290b4a9de..4ccd2c72ca 100644 --- a/util/stream/zlib_ut.cpp +++ b/util/stream/zlib_ut.cpp @@ -76,8 +76,8 @@ Y_UNIT_TEST_SUITE(TZLibTest) { } Y_UNIT_TEST(Dictionary) { - static constexpr TStringBuf data = "<html><body></body></html>"; - static constexpr TStringBuf dict = "</<html><body>"; + static constexpr TStringBuf data = "<html><body></body></html>"; + static constexpr TStringBuf dict = "</<html><body>"; for (auto type : {ZLib::Raw, ZLib::ZLib}) { TStringStream compressed; { diff --git a/util/string/ascii_ut.cpp b/util/string/ascii_ut.cpp index 89069fee50..d4a31f61b6 100644 --- a/util/string/ascii_ut.cpp +++ b/util/string/ascii_ut.cpp @@ -64,7 +64,7 @@ Y_UNIT_TEST_SUITE(TAsciiTest) { Y_UNIT_TEST(CompareTest) { UNIT_ASSERT(AsciiEqualsIgnoreCase("qqq", "qQq")); - UNIT_ASSERT(AsciiEqualsIgnoreCase("qqq", TStringBuf("qQq"))); + UNIT_ASSERT(AsciiEqualsIgnoreCase("qqq", TStringBuf("qQq"))); TString qq = "qq"; TString qQ = "qQ"; UNIT_ASSERT(AsciiEqualsIgnoreCase(qq, qQ)); diff --git a/util/string/cast.cpp b/util/string/cast.cpp index aa1e65a8e9..2a4f697042 100644 --- a/util/string/cast.cpp +++ b/util/string/cast.cpp @@ -6,7 +6,7 @@ #include <cstdio> #include <string> -#include <cmath> +#include <cmath> #include <util/string/type.h> #include <util/string/cast.h> @@ -31,12 +31,12 @@ using double_conversion::StringToDoubleConverter; */ namespace { - constexpr char IntToChar[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + constexpr char IntToChar[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; static_assert(Y_ARRAY_SIZE(IntToChar) == 16, "expect Y_ARRAY_SIZE(IntToChar) == 16"); // clang-format off - constexpr int LetterToIntMap[] = { + constexpr int LetterToIntMap[] = { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, @@ -52,17 +52,17 @@ namespace { // clang-format on template <class T> - std::enable_if_t<std::is_signed<T>::value, std::make_unsigned_t<T>> NegateNegativeSigned(T value) noexcept { + std::enable_if_t<std::is_signed<T>::value, std::make_unsigned_t<T>> NegateNegativeSigned(T value) noexcept { return std::make_unsigned_t<T>(-(value + 1)) + std::make_unsigned_t<T>(1); } template <class T> - std::enable_if_t<std::is_unsigned<T>::value, std::make_unsigned_t<T>> NegateNegativeSigned(T) noexcept { + std::enable_if_t<std::is_unsigned<T>::value, std::make_unsigned_t<T>> NegateNegativeSigned(T) noexcept { Y_UNREACHABLE(); } template <class T> - std::make_signed_t<T> NegatePositiveSigned(T value) noexcept { + std::make_signed_t<T> NegatePositiveSigned(T value) noexcept { return value > 0 ? (-std::make_signed_t<T>(value - 1) - 1) : 0; } @@ -72,18 +72,18 @@ namespace { static_assert(std::is_unsigned<T>::value, "TBasicIntFormatter can only handle unsigned integers."); static inline size_t Format(T value, TChar* buf, size_t len) { - Y_ENSURE(len, TStringBuf("zero length")); + Y_ENSURE(len, TStringBuf("zero length")); TChar* tmp = buf; do { - // divide only once, do not use mod - const T nextVal = static_cast<T>(value / base); - *tmp++ = IntToChar[base == 2 || base == 4 || base == 8 || base == 16 ? value & (base - 1) : value - base * nextVal]; - value = nextVal; + // divide only once, do not use mod + const T nextVal = static_cast<T>(value / base); + *tmp++ = IntToChar[base == 2 || base == 4 || base == 8 || base == 16 ? value & (base - 1) : value - base * nextVal]; + value = nextVal; } while (value && --len); - Y_ENSURE(!value, TStringBuf("not enough room in buffer")); + Y_ENSURE(!value, TStringBuf("not enough room in buffer")); const size_t result = tmp - buf; @@ -111,7 +111,7 @@ namespace { using TUFmt = TBasicIntFormatter<std::make_unsigned_t<T>, base, TChar>; if (std::is_signed<T>::value && value < 0) { - Y_ENSURE(len >= 2, TStringBuf("not enough room in buffer")); + Y_ENSURE(len >= 2, TStringBuf("not enough room in buffer")); *buf = '-'; @@ -126,15 +126,15 @@ namespace { struct TFltModifiers; template <class T, int base, class TChar> - Y_NO_INLINE size_t FormatInt(T value, TChar* buf, size_t len) { + Y_NO_INLINE size_t FormatInt(T value, TChar* buf, size_t len) { return TIntFormatter<T, base, TChar>::Format(value, buf, len); } template <class T> - inline size_t FormatFlt(T t, char* buf, size_t len) { + inline size_t FormatFlt(T t, char* buf, size_t len) { const int ret = snprintf(buf, len, TFltModifiers<T>::ModifierWrite, t); - Y_ENSURE(ret >= 0 && (size_t)ret <= len, TStringBuf("cannot format float")); + Y_ENSURE(ret >= 0 && (size_t)ret <= len, TStringBuf("cannot format float")); return (size_t)ret; } @@ -148,7 +148,7 @@ namespace { PS_OVERFLOW, }; - constexpr ui8 SAFE_LENS[4][17] = { + constexpr ui8 SAFE_LENS[4][17] = { {0, 0, 7, 5, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1}, {0, 0, 15, 10, 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3}, {0, 0, 31, 20, 15, 13, 12, 11, 10, 10, 9, 9, 8, 8, 8, 8, 7}, @@ -160,7 +160,7 @@ namespace { } template <unsigned BASE, class TChar, class T> - inline std::enable_if_t<(BASE > 10), bool> CharToDigit(TChar c, T* digit) noexcept { + inline std::enable_if_t<(BASE > 10), bool> CharToDigit(TChar c, T* digit) noexcept { unsigned uc = c; if (uc >= Y_ARRAY_SIZE(LetterToIntMap)) { @@ -173,7 +173,7 @@ namespace { } template <unsigned BASE, class TChar, class T> - inline std::enable_if_t<(BASE <= 10), bool> CharToDigit(TChar c, T* digit) noexcept { + inline std::enable_if_t<(BASE <= 10), bool> CharToDigit(TChar c, T* digit) noexcept { return (c >= '0') && ((*digit = (c - '0')) < BASE); } @@ -284,7 +284,7 @@ namespace { return PS_EMPTY_STRING; } - bool negative = false; + bool negative = false; TUnsigned max; if (*pos == '+') { pos++; @@ -329,22 +329,22 @@ namespace { switch (status) { case PS_EMPTY_STRING: - ythrow TFromStringException() << TStringBuf("Cannot parse empty string as number. "); + ythrow TFromStringException() << TStringBuf("Cannot parse empty string as number. "); case PS_PLUS_STRING: - ythrow TFromStringException() << TStringBuf("Cannot parse string \"+\" as number. "); + ythrow TFromStringException() << TStringBuf("Cannot parse string \"+\" as number. "); case PS_MINUS_STRING: - ythrow TFromStringException() << TStringBuf("Cannot parse string \"-\" as number. "); + ythrow TFromStringException() << TStringBuf("Cannot parse string \"-\" as number. "); case PS_BAD_SYMBOL: - ythrow TFromStringException() << TStringBuf("Unexpected symbol \"") << EscapeC(*pos) << TStringBuf("\" at pos ") << (pos - data) << TStringBuf(" in string ") << TStringType(data, len).Quote() << TStringBuf(". "); + ythrow TFromStringException() << TStringBuf("Unexpected symbol \"") << EscapeC(*pos) << TStringBuf("\" at pos ") << (pos - data) << TStringBuf(" in string ") << TStringType(data, len).Quote() << TStringBuf(". "); case PS_OVERFLOW: - ythrow TFromStringException() << TStringBuf("Integer overflow in string ") << TStringType(data, len).Quote() << TStringBuf(". "); + ythrow TFromStringException() << TStringBuf("Integer overflow in string ") << TStringType(data, len).Quote() << TStringBuf(". "); default: - ythrow yexception() << TStringBuf("Unknown error code in string converter. "); + ythrow yexception() << TStringBuf("Unknown error code in string converter. "); } } template <typename T, typename TUnsigned, int base, typename TChar> - Y_NO_INLINE T ParseInt(const TChar* data, size_t len, const TBounds<TUnsigned>& bounds) { + Y_NO_INLINE T ParseInt(const TChar* data, size_t len, const TBounds<TUnsigned>& bounds) { T result; const TChar* pos = data; EParseStatus status = TIntParser<T, base, TChar>::Parse(&pos, pos + len, bounds, &result); @@ -357,12 +357,12 @@ namespace { } template <typename T, typename TUnsigned, int base, typename TChar> - Y_NO_INLINE bool TryParseInt(const TChar* data, size_t len, const TBounds<TUnsigned>& bounds, T* result) { + Y_NO_INLINE bool TryParseInt(const TChar* data, size_t len, const TBounds<TUnsigned>& bounds, T* result) { return TIntParser<T, base, TChar>::Parse(&data, data + len, bounds, result) == PS_OK; } template <class T> - inline T ParseFlt(const char* data, size_t len) { + inline T ParseFlt(const char* data, size_t len) { /* * TODO */ @@ -384,7 +384,7 @@ namespace { return ret; } - ythrow TFromStringException() << TStringBuf("cannot parse float(") << TStringBuf(data, len) << TStringBuf(")"); + ythrow TFromStringException() << TStringBuf("cannot parse float(") << TStringBuf(data, len) << TStringBuf(")"); } #define DEF_FLT_MOD(type, modifierWrite, modifierRead) \ @@ -405,16 +405,16 @@ namespace { * sure they go into binary as actual values and there is no associated * initialization code. * */ - constexpr TBounds<ui64> bSBounds = {static_cast<ui64>(SCHAR_MAX), static_cast<ui64>(UCHAR_MAX - SCHAR_MAX)}; - constexpr TBounds<ui64> bUBounds = {static_cast<ui64>(UCHAR_MAX), 0}; - constexpr TBounds<ui64> sSBounds = {static_cast<ui64>(SHRT_MAX), static_cast<ui64>(USHRT_MAX - SHRT_MAX)}; - constexpr TBounds<ui64> sUBounds = {static_cast<ui64>(USHRT_MAX), 0}; - constexpr TBounds<ui64> iSBounds = {static_cast<ui64>(INT_MAX), static_cast<ui64>(UINT_MAX - INT_MAX)}; - constexpr TBounds<ui64> iUBounds = {static_cast<ui64>(UINT_MAX), 0}; - constexpr TBounds<ui64> lSBounds = {static_cast<ui64>(LONG_MAX), static_cast<ui64>(ULONG_MAX - LONG_MAX)}; - constexpr TBounds<ui64> lUBounds = {static_cast<ui64>(ULONG_MAX), 0}; - constexpr TBounds<ui64> llSBounds = {static_cast<ui64>(LLONG_MAX), static_cast<ui64>(ULLONG_MAX - LLONG_MAX)}; - constexpr TBounds<ui64> llUBounds = {static_cast<ui64>(ULLONG_MAX), 0}; + constexpr TBounds<ui64> bSBounds = {static_cast<ui64>(SCHAR_MAX), static_cast<ui64>(UCHAR_MAX - SCHAR_MAX)}; + constexpr TBounds<ui64> bUBounds = {static_cast<ui64>(UCHAR_MAX), 0}; + constexpr TBounds<ui64> sSBounds = {static_cast<ui64>(SHRT_MAX), static_cast<ui64>(USHRT_MAX - SHRT_MAX)}; + constexpr TBounds<ui64> sUBounds = {static_cast<ui64>(USHRT_MAX), 0}; + constexpr TBounds<ui64> iSBounds = {static_cast<ui64>(INT_MAX), static_cast<ui64>(UINT_MAX - INT_MAX)}; + constexpr TBounds<ui64> iUBounds = {static_cast<ui64>(UINT_MAX), 0}; + constexpr TBounds<ui64> lSBounds = {static_cast<ui64>(LONG_MAX), static_cast<ui64>(ULONG_MAX - LONG_MAX)}; + constexpr TBounds<ui64> lUBounds = {static_cast<ui64>(ULONG_MAX), 0}; + constexpr TBounds<ui64> llSBounds = {static_cast<ui64>(LLONG_MAX), static_cast<ui64>(ULLONG_MAX - LLONG_MAX)}; + constexpr TBounds<ui64> llUBounds = {static_cast<ui64>(ULLONG_MAX), 0}; } #define DEF_INT_SPEC_II(TYPE, ITYPE, BASE) \ @@ -474,7 +474,7 @@ DEF_FLT_SPEC(long double) template <> size_t ToStringImpl<bool>(bool t, char* buf, size_t len) { - Y_ENSURE(len, TStringBuf("zero length")); + Y_ENSURE(len, TStringBuf("zero length")); *buf = t ? '1' : '0'; return 1; } @@ -510,7 +510,7 @@ bool FromStringImpl<bool>(const char* data, size_t len) { bool result; if (!TryFromStringImpl<bool>(data, len, result)) { - ythrow TFromStringException() << TStringBuf("Cannot parse bool(") << TStringBuf(data, len) << TStringBuf("). "); + ythrow TFromStringException() << TStringBuf("Cannot parse bool(") << TStringBuf(data, len) << TStringBuf("). "); } return result; @@ -683,7 +683,7 @@ template <> double FromStringImpl<double>(const char* data, size_t len) { double d = 0.0; if (!TryFromStringImpl(data, len, d)) { - ythrow TFromStringException() << TStringBuf("cannot parse float(") << TStringBuf(data, len) << TStringBuf(")"); + ythrow TFromStringException() << TStringBuf("cannot parse float(") << TStringBuf(data, len) << TStringBuf(")"); } return d; } diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp index 033450c38c..1a1d6c5d91 100644 --- a/util/string/cast_ut.cpp +++ b/util/string/cast_ut.cpp @@ -282,10 +282,10 @@ Y_UNIT_TEST_SUITE(TCastTest) { UNIT_ASSERT_STRINGS_EQUAL(FloatToString(std::numeric_limits<double>::quiet_NaN()), "nan"); UNIT_ASSERT_STRINGS_EQUAL(FloatToString(std::numeric_limits<double>::infinity()), "inf"); - UNIT_ASSERT_STRINGS_EQUAL(FloatToString(-std::numeric_limits<double>::infinity()), "-inf"); - - UNIT_ASSERT_STRINGS_EQUAL(FloatToString(std::numeric_limits<float>::quiet_NaN()), "nan"); - UNIT_ASSERT_STRINGS_EQUAL(FloatToString(std::numeric_limits<float>::infinity()), "inf"); + UNIT_ASSERT_STRINGS_EQUAL(FloatToString(-std::numeric_limits<double>::infinity()), "-inf"); + + UNIT_ASSERT_STRINGS_EQUAL(FloatToString(std::numeric_limits<float>::quiet_NaN()), "nan"); + UNIT_ASSERT_STRINGS_EQUAL(FloatToString(std::numeric_limits<float>::infinity()), "inf"); UNIT_ASSERT_STRINGS_EQUAL(FloatToString(-std::numeric_limits<float>::infinity()), "-inf"); } @@ -452,7 +452,7 @@ Y_UNIT_TEST_SUITE(TCastTest) { Y_UNIT_TEST(TestAutoDetectType) { UNIT_ASSERT_DOUBLES_EQUAL((float)FromString("0.0001"), 0.0001, EPS); UNIT_ASSERT_DOUBLES_EQUAL((double)FromString("0.0015", sizeof("0.0015") - 2), 0.001, EPS); - UNIT_ASSERT_DOUBLES_EQUAL((long double)FromString(TStringBuf("0.0001")), 0.0001, EPS); + UNIT_ASSERT_DOUBLES_EQUAL((long double)FromString(TStringBuf("0.0001")), 0.0001, EPS); UNIT_ASSERT_DOUBLES_EQUAL((float)FromString(TString("10E-5")), 10E-5, EPS); UNIT_ASSERT_VALUES_EQUAL((bool)FromString("da"), true); UNIT_ASSERT_VALUES_EQUAL((bool)FromString("no"), false); @@ -512,13 +512,13 @@ Y_UNIT_TEST_SUITE(TCastTest) { Y_UNIT_TEST(TryStringBuf) { { - constexpr TStringBuf hello = "hello"; + constexpr TStringBuf hello = "hello"; TStringBuf out; UNIT_ASSERT(TryFromString(hello, out)); UNIT_ASSERT_VALUES_EQUAL(hello, out); } { - constexpr TStringBuf empty = ""; + constexpr TStringBuf empty = ""; TStringBuf out; UNIT_ASSERT(TryFromString(empty, out)); UNIT_ASSERT_VALUES_EQUAL(empty, out); diff --git a/util/string/escape_ut.cpp b/util/string/escape_ut.cpp index cd38ecffd3..68513df10c 100644 --- a/util/string/escape_ut.cpp +++ b/util/string/escape_ut.cpp @@ -5,8 +5,8 @@ #include <util/generic/string.h> #include <util/charset/wide.h> -using namespace std::string_view_literals; - +using namespace std::string_view_literals; + namespace { struct TExample { TString Expected; @@ -22,11 +22,11 @@ namespace { static const TExample CommonTestData[] = { // Should be valid UTF-8. - {"http://ya.ru/", "http://ya.ru/"}, - {"http://ya.ru/\\x17\\n", "http://ya.ru/\x17\n"}, + {"http://ya.ru/", "http://ya.ru/"}, + {"http://ya.ru/\\x17\\n", "http://ya.ru/\x17\n"}, - {"http://ya.ru/\\0", "http://ya.ru/\0"sv}, - {"http://ya.ru/\\0\\0", "http://ya.ru/\0\0"sv}, + {"http://ya.ru/\\0", "http://ya.ru/\0"sv}, + {"http://ya.ru/\\0\\0", "http://ya.ru/\0\0"sv}, {"http://ya.ru/\\0\\0000", "http://ya.ru/\0\0" "0"sv}, {"http://ya.ru/\\0\\0001", "http://ya.ru/\0\x00" @@ -37,13 +37,13 @@ static const TExample CommonTestData[] = { {R"(\2\4\689)", "\2\4\6" "89"sv}, // \6 -> \6 because next char '8' is not "octal" - {R"(\"Hello\", Alice said.)", "\"Hello\", Alice said."}, - {"Slash\\\\dash!", "Slash\\dash!"}, - {R"(There\nare\r\nnewlines.)", "There\nare\r\nnewlines."}, - {"There\\tare\\ttabs.", "There\tare\ttabs."}, + {R"(\"Hello\", Alice said.)", "\"Hello\", Alice said."}, + {"Slash\\\\dash!", "Slash\\dash!"}, + {R"(There\nare\r\nnewlines.)", "There\nare\r\nnewlines."}, + {"There\\tare\\ttabs.", "There\tare\ttabs."}, - {"There are questions \\x3F\\x3F?", "There are questions ???"}, - {"There are questions \\x3F?", "There are questions ??"}, + {"There are questions \\x3F\\x3F?", "There are questions ???"}, + {"There are questions \\x3F?", "There are questions ??"}, }; Y_UNIT_TEST_SUITE(TEscapeCTest) { diff --git a/util/string/hex.cpp b/util/string/hex.cpp index 667397987f..4d5ea72e7d 100644 --- a/util/string/hex.cpp +++ b/util/string/hex.cpp @@ -32,7 +32,7 @@ char* HexEncode(const void* in, size_t len, char* out) { void* HexDecode(const void* in, size_t len, void* ptr) { const char* b = (const char*)in; const char* e = b + len; - Y_ENSURE(!(len & 1), TStringBuf("Odd buffer length passed to HexDecode")); + Y_ENSURE(!(len & 1), TStringBuf("Odd buffer length passed to HexDecode")); char* out = (char*)ptr; diff --git a/util/string/join_ut.cpp b/util/string/join_ut.cpp index 3ed2b2459c..f23d2c0440 100644 --- a/util/string/join_ut.cpp +++ b/util/string/join_ut.cpp @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(JoinStringTest) { UNIT_ASSERT_EQUAL(Join(", ", 10, 11.1, "foobar"), "10, 11.1, foobar"); UNIT_ASSERT_EQUAL(Join(", ", 10, 11.1, TString("foobar")), "10, 11.1, foobar"); - UNIT_ASSERT_EQUAL(Join('#', 0, "a", "foobar", -1.4, TStringBuf("aaa")), "0#a#foobar#-1.4#aaa"); + UNIT_ASSERT_EQUAL(Join('#', 0, "a", "foobar", -1.4, TStringBuf("aaa")), "0#a#foobar#-1.4#aaa"); UNIT_ASSERT_EQUAL(Join("", "", ""), ""); UNIT_ASSERT_EQUAL(Join("", "a", "b", "c"), "abc"); UNIT_ASSERT_EQUAL(Join("", "a", "b", "", "c"), "abc"); diff --git a/util/string/split.h b/util/string/split.h index bc46d9e64c..401d75bdd9 100644 --- a/util/string/split.h +++ b/util/string/split.h @@ -427,7 +427,7 @@ inline size_t Split(const TStringBuf s, const TSetDelimiter<const char>& delim, template <class P, class D> void GetNext(TStringBuf& s, D delim, P& param) { TStringBuf next = s.NextTok(delim); - Y_ENSURE(next.IsInited(), TStringBuf("Split: number of fields less than number of Split output arguments")); + Y_ENSURE(next.IsInited(), TStringBuf("Split: number of fields less than number of Split output arguments")); param = FromString<P>(next); } @@ -442,12 +442,12 @@ void GetNext(TStringBuf& s, D delim, TMaybe<P>& param) { } // example: -// Split(TStringBuf("Sherlock,2014,36.6"), ',', name, year, temperature); +// Split(TStringBuf("Sherlock,2014,36.6"), ',', name, year, temperature); template <class D, class P1, class P2> void Split(TStringBuf s, D delim, P1& p1, P2& p2) { GetNext(s, delim, p1); GetNext(s, delim, p2); - Y_ENSURE(!s.IsInited(), TStringBuf("Split: number of fields more than number of Split output arguments")); + Y_ENSURE(!s.IsInited(), TStringBuf("Split: number of fields more than number of Split output arguments")); } template <class D, class P1, class P2, class... Other> diff --git a/util/string/split_ut.cpp b/util/string/split_ut.cpp index 43e59f2d75..7f4c0d6d23 100644 --- a/util/string/split_ut.cpp +++ b/util/string/split_ut.cpp @@ -648,7 +648,7 @@ Y_UNIT_TEST_SUITE(StringSplitter) { TVector<TString> actual1 = {"another", "one,", "and", "another", "one"}; num = 0; - for (TStringBuf elem : StringSplitter(TStringBuf("another one, and \n\n another one")).SplitBySet(" \n").SkipEmpty()) { + for (TStringBuf elem : StringSplitter(TStringBuf("another one, and \n\n another one")).SplitBySet(" \n").SkipEmpty()) { UNIT_ASSERT_VALUES_EQUAL(elem, actual1[num++]); } diff --git a/util/string/strip_ut.cpp b/util/string/strip_ut.cpp index d1029d1498..84451b467c 100644 --- a/util/string/strip_ut.cpp +++ b/util/string/strip_ut.cpp @@ -94,15 +94,15 @@ Y_UNIT_TEST_SUITE(TStripStringTest) { } Y_UNIT_TEST(TestWtrokaStrip) { - UNIT_ASSERT_EQUAL(StripString(TWtringBuf(u" abc ")), u"abc"); - UNIT_ASSERT_EQUAL(StripStringLeft(TWtringBuf(u" abc ")), u"abc "); - UNIT_ASSERT_EQUAL(StripStringRight(TWtringBuf(u" abc ")), u" abc"); + UNIT_ASSERT_EQUAL(StripString(TWtringBuf(u" abc ")), u"abc"); + UNIT_ASSERT_EQUAL(StripStringLeft(TWtringBuf(u" abc ")), u"abc "); + UNIT_ASSERT_EQUAL(StripStringRight(TWtringBuf(u" abc ")), u" abc"); } Y_UNIT_TEST(TestWtrokaCustomStrip) { UNIT_ASSERT_EQUAL( StripString( - TWtringBuf(u"/abc/"), + TWtringBuf(u"/abc/"), EqualsStripAdapter(u'/')), u"abc"); } diff --git a/util/string/type.cpp b/util/string/type.cpp index 49671c02c2..3fbc547fc6 100644 --- a/util/string/type.cpp +++ b/util/string/type.cpp @@ -17,38 +17,38 @@ bool IsSpace(const char* s, size_t len) noexcept { template <typename TStringType> static bool IsNumberT(const TStringType& s) noexcept { - if (s.empty()) { - return false; - } - + if (s.empty()) { + return false; + } + return std::all_of(s.begin(), s.end(), IsAsciiDigit<typename TStringType::value_type>); -} - +} + bool IsNumber(const TStringBuf s) noexcept { - return IsNumberT(s); -} - + return IsNumberT(s); +} + bool IsNumber(const TWtringBuf s) noexcept { - return IsNumberT(s); -} - + return IsNumberT(s); +} + template <typename TStringType> static bool IsHexNumberT(const TStringType& s) noexcept { - if (s.empty()) { + if (s.empty()) { return false; - } + } return std::all_of(s.begin(), s.end(), IsAsciiHex<typename TStringType::value_type>); } bool IsHexNumber(const TStringBuf s) noexcept { - return IsHexNumberT(s); -} - + return IsHexNumberT(s); +} + bool IsHexNumber(const TWtringBuf s) noexcept { - return IsHexNumberT(s); -} - + return IsHexNumberT(s); +} + namespace { template <size_t N> bool IsCaseInsensitiveAnyOf(TStringBuf str, const std::array<TStringBuf, N>& options) { @@ -63,24 +63,24 @@ namespace { bool IsTrue(const TStringBuf v) noexcept { static constexpr std::array<TStringBuf, 7> trueOptions{ - "true", - "t", - "yes", - "y", - "on", - "1", - "da"}; + "true", + "t", + "yes", + "y", + "on", + "1", + "da"}; return IsCaseInsensitiveAnyOf(v, trueOptions); } bool IsFalse(const TStringBuf v) noexcept { static constexpr std::array<TStringBuf, 7> falseOptions{ - "false", - "f", - "no", - "n", - "off", - "0", - "net"}; + "false", + "f", + "no", + "n", + "off", + "0", + "net"}; return IsCaseInsensitiveAnyOf(v, falseOptions); } diff --git a/util/string/type.h b/util/string/type.h index d6cb29ea58..a868cc265a 100644 --- a/util/string/type.h +++ b/util/string/type.h @@ -18,7 +18,7 @@ Y_PURE_FUNCTION bool IsNumber(const TWtringBuf s) noexcept; Y_PURE_FUNCTION bool IsHexNumber(const TStringBuf s) noexcept; Y_PURE_FUNCTION bool IsHexNumber(const TWtringBuf s) noexcept; - + /* Tests if the given string is case insensitive equal to one of: * - "true", * - "t", diff --git a/util/string/type_ut.cpp b/util/string/type_ut.cpp index 03e7af62bd..d41b7edb37 100644 --- a/util/string/type_ut.cpp +++ b/util/string/type_ut.cpp @@ -2,8 +2,8 @@ #include <library/cpp/testing/unittest/registar.h> -#include <util/charset/wide.h> - +#include <util/charset/wide.h> + Y_UNIT_TEST_SUITE(TStringClassify) { Y_UNIT_TEST(TestIsSpace) { UNIT_ASSERT_EQUAL(IsSpace(" "), true); @@ -38,32 +38,32 @@ Y_UNIT_TEST_SUITE(TStringClassify) { UNIT_ASSERT(!IsFalse("fa")); UNIT_ASSERT(!IsFalse("foobar")); } - + Y_UNIT_TEST(TestIsNumber) { - UNIT_ASSERT(IsNumber("0")); - UNIT_ASSERT(IsNumber("12345678901234567890")); - UNIT_ASSERT(!IsNumber("1234567890a")); - UNIT_ASSERT(!IsNumber("12345xx67890a")); - UNIT_ASSERT(!IsNumber("foobar")); + UNIT_ASSERT(IsNumber("0")); + UNIT_ASSERT(IsNumber("12345678901234567890")); + UNIT_ASSERT(!IsNumber("1234567890a")); + UNIT_ASSERT(!IsNumber("12345xx67890a")); + UNIT_ASSERT(!IsNumber("foobar")); UNIT_ASSERT(!IsNumber("")); - + UNIT_ASSERT(IsNumber(u"0")); UNIT_ASSERT(IsNumber(u"12345678901234567890")); UNIT_ASSERT(!IsNumber(u"1234567890a")); UNIT_ASSERT(!IsNumber(u"12345xx67890a")); UNIT_ASSERT(!IsNumber(u"foobar")); - } - + } + Y_UNIT_TEST(TestIsHexNumber) { - UNIT_ASSERT(IsHexNumber("0")); - UNIT_ASSERT(IsHexNumber("aaaadddAAAAA")); - UNIT_ASSERT(IsHexNumber("0123456789ABCDEFabcdef")); - UNIT_ASSERT(IsHexNumber("12345678901234567890")); - UNIT_ASSERT(IsHexNumber("1234567890a")); - UNIT_ASSERT(!IsHexNumber("12345xx67890a")); - UNIT_ASSERT(!IsHexNumber("foobar")); + UNIT_ASSERT(IsHexNumber("0")); + UNIT_ASSERT(IsHexNumber("aaaadddAAAAA")); + UNIT_ASSERT(IsHexNumber("0123456789ABCDEFabcdef")); + UNIT_ASSERT(IsHexNumber("12345678901234567890")); + UNIT_ASSERT(IsHexNumber("1234567890a")); + UNIT_ASSERT(!IsHexNumber("12345xx67890a")); + UNIT_ASSERT(!IsHexNumber("foobar")); UNIT_ASSERT(!IsHexNumber(TString())); - + UNIT_ASSERT(IsHexNumber(u"0")); UNIT_ASSERT(IsHexNumber(u"aaaadddAAAAA")); UNIT_ASSERT(IsHexNumber(u"0123456789ABCDEFabcdef")); @@ -72,5 +72,5 @@ Y_UNIT_TEST_SUITE(TStringClassify) { UNIT_ASSERT(!IsHexNumber(u"12345xx67890a")); UNIT_ASSERT(!IsHexNumber(u"foobar")); UNIT_ASSERT(!IsHexNumber(TUtf16String())); - } + } } diff --git a/util/string/util.h b/util/string/util.h index 0d77a5042b..24fcaa5bb8 100644 --- a/util/string/util.h +++ b/util/string/util.h @@ -73,13 +73,13 @@ public: /// [DIFFERENCE FOR NOT_FOUND CASE: Returns end of string, not NULL] const char* brk(const char* s) const { while (c_chars_table[(ui8)*s]) - ++s; + ++s; return s; } const char* brk(const char* s, const char* e) const { while (s < e && c_chars_table[(ui8)*s]) - ++s; + ++s; return s; } @@ -87,13 +87,13 @@ public: /// That is, skip all characters in table const char* cbrk(const char* s) const { while (chars_table[(ui8)*s]) - ++s; + ++s; return s; } const char* cbrk(const char* s, const char* e) const { while (s < e && chars_table[(ui8)*s]) - ++s; + ++s; return s; } @@ -148,7 +148,7 @@ public: protected: void init(const char* charset, bool extended); - str_spn() = default; + str_spn() = default; }; // an analogue of tr/$from/$to/ diff --git a/util/system/backtrace.cpp b/util/system/backtrace.cpp index b77fe58fb1..68e4121cab 100644 --- a/util/system/backtrace.cpp +++ b/util/system/backtrace.cpp @@ -149,8 +149,8 @@ TResolvedSymbol ResolveSymbol(void* sym, char* buf, size_t len) { return ret; } #elif defined(_win_) - #include <util/generic/singleton.h> - + #include <util/generic/singleton.h> + namespace { struct TWinSymbolResolverImpl { typedef BOOL(WINAPI* TSymInitializeFunc)(HANDLE, PCSTR, BOOL); diff --git a/util/system/context.cpp b/util/system/context.cpp index ad99309088..4c67affa1f 100644 --- a/util/system/context.cpp +++ b/util/system/context.cpp @@ -221,14 +221,14 @@ TContMachineContext::TContMachineContext() : Fiber_(ConvertThreadToFiber(this)) , MainFiber_(true) { - Y_ENSURE(Fiber_, TStringBuf("fiber error")); + Y_ENSURE(Fiber_, TStringBuf("fiber error")); } TContMachineContext::TContMachineContext(const TContClosure& c) : Fiber_(CreateFiber(c.Stack.size(), (LPFIBER_START_ROUTINE)ContextTrampoLine, (LPVOID)c.TrampoLine)) , MainFiber_(false) { - Y_ENSURE(Fiber_, TStringBuf("fiber error")); + Y_ENSURE(Fiber_, TStringBuf("fiber error")); } TContMachineContext::~TContMachineContext() { diff --git a/util/system/datetime.cpp b/util/system/datetime.cpp index b07b50679a..94ce01df78 100644 --- a/util/system/datetime.cpp +++ b/util/system/datetime.cpp @@ -5,8 +5,8 @@ #include <util/datetime/systime.h> -#include <ctime> -#include <cerrno> +#include <ctime> +#include <cerrno> #ifdef _darwin_ #include <AvailabilityMacros.h> diff --git a/util/system/dynlib.cpp b/util/system/dynlib.cpp index 9d2541c25f..14dfb625f2 100644 --- a/util/system/dynlib.cpp +++ b/util/system/dynlib.cpp @@ -18,7 +18,7 @@ #define RTLD_GLOBAL (0) #endif -using HINSTANCE = void*; +using HINSTANCE = void*; #define DLLOPEN(path, flags) dlopen(path, flags) #define DLLCLOSE(hndl) dlclose(hndl) @@ -37,7 +37,7 @@ inline TString DLLERR() { if (!msg) return "DLLERR() unknown error"; while (cnt && isspace(msg[cnt - 1])) - --cnt; + --cnt; TString err(msg, 0, cnt); LocalFree(msg); return err; diff --git a/util/system/env.cpp b/util/system/env.cpp index ead9b566a5..09dfc8271a 100644 --- a/util/system/env.cpp +++ b/util/system/env.cpp @@ -18,7 +18,7 @@ * * Relevant links: * - http://bugs.python.org/issue16633 - * - https://a.yandex-team.ru/review/108892/details + * - https://a.yandex-team.ru/review/108892/details */ TString GetEnv(const TString& key, const TString& def) { diff --git a/util/system/file.cpp b/util/system/file.cpp index 4a261d020c..2beb6a8e3b 100644 --- a/util/system/file.cpp +++ b/util/system/file.cpp @@ -784,9 +784,9 @@ TString DecodeOpenMode(ui32 mode0) { if ((mode & flag) == flag) { \ mode &= ~flag; \ if (r) { \ - r << TStringBuf("|"); \ + r << TStringBuf("|"); \ } \ - r << TStringBuf(#flag); \ + r << TStringBuf(#flag); \ } F(RdWr) @@ -828,7 +828,7 @@ TString DecodeOpenMode(ui32 mode0) { if (mode != 0) { if (r) { - r << TStringBuf("|"); + r << TStringBuf("|"); } r << Hex(mode); diff --git a/util/system/file_lock.cpp b/util/system/file_lock.cpp index 45d91282c5..f10cc089e0 100644 --- a/util/system/file_lock.cpp +++ b/util/system/file_lock.cpp @@ -3,7 +3,7 @@ #include <util/generic/yexception.h> -#include <cerrno> +#include <cerrno> namespace { int GetMode(const EFileLockType type) { diff --git a/util/system/fstat.cpp b/util/system/fstat.cpp index 81e98cbc6b..4a1562f60a 100644 --- a/util/system/fstat.cpp +++ b/util/system/fstat.cpp @@ -5,7 +5,7 @@ #include <util/folder/path.h> -#include <cerrno> +#include <cerrno> #if defined(_win_) #include "fs_win.h" @@ -96,7 +96,7 @@ static bool GetStatByName(TSystemFStat& fs, const char* fileName, bool nofollow) #endif } -TFileStat::TFileStat() = default; +TFileStat::TFileStat() = default; TFileStat::TFileStat(const TFile& f) { *this = TFileStat(f.GetHandle()); diff --git a/util/system/info.cpp b/util/system/info.cpp index cf6681e89a..6546cca238 100644 --- a/util/system/info.cpp +++ b/util/system/info.cpp @@ -106,11 +106,11 @@ size_t NSystemInfo::NumberOfCpus() { column = 0; } else if (column != -1) { if (AsciiToLower(ch) == matchstr[column]) { - ++column; + ++column; if (column == sizeof(matchstr) - 1) { column = -1; - ++ret; + ++ret; } } else { column = -1; diff --git a/util/system/mem_info.cpp b/util/system/mem_info.cpp index aa51ae3b16..7016b01089 100644 --- a/util/system/mem_info.cpp +++ b/util/system/mem_info.cpp @@ -25,7 +25,7 @@ #include <Windows.h> #include <util/generic/ptr.h> -using NTSTATUS = LONG; +using NTSTATUS = LONG; #define STATUS_INFO_LENGTH_MISMATCH 0xC0000004 #define STATUS_BUFFER_TOO_SMALL 0xC0000023 @@ -38,7 +38,7 @@ typedef struct _CLIENT_ID { HANDLE UniqueProcess; HANDLE UniqueThread; } CLIENT_ID, *PCLIENT_ID; -using KWAIT_REASON = ULONG; +using KWAIT_REASON = ULONG; typedef struct _SYSTEM_THREAD_INFORMATION { LARGE_INTEGER KernelTime; LARGE_INTEGER UserTime; diff --git a/util/system/rwlock.cpp b/util/system/rwlock.cpp index bb3dcbf188..9f9b3975c0 100644 --- a/util/system/rwlock.cpp +++ b/util/system/rwlock.cpp @@ -51,7 +51,7 @@ void TRWMutex::TImpl::AcquireRead() noexcept { ReadCond_.Wait(Lock_); } - ++State_; + ++State_; } ReadCond_.Signal(); @@ -63,7 +63,7 @@ bool TRWMutex::TImpl::TryAcquireRead() noexcept { return false; } - ++State_; + ++State_; } return true; diff --git a/util/system/sem.cpp b/util/system/sem.cpp index 4a93b903b5..d7c2bca19c 100644 --- a/util/system/sem.cpp +++ b/util/system/sem.cpp @@ -49,12 +49,12 @@ namespace { class TSemaphoreImpl { private: #ifdef _win_ - using SEMHANDLE = HANDLE; + using SEMHANDLE = HANDLE; #else #ifdef USE_SYSV_SEMAPHORES - using SEMHANDLE = int; + using SEMHANDLE = int; #else - using SEMHANDLE = sem_t*; + using SEMHANDLE = sem_t*; #endif #endif @@ -76,7 +76,7 @@ namespace { while (*p) { if (*p == '\\') *p = '/'; - ++p; + ++p; } } // non-blocking on init diff --git a/util/system/shellcommand.cpp b/util/system/shellcommand.cpp index b1989b5c8c..c6cd634190 100644 --- a/util/system/shellcommand.cpp +++ b/util/system/shellcommand.cpp @@ -109,7 +109,7 @@ namespace { // temporary measure to avoid rewriting all poll calls on win TPipeHandle #if defined(_win_) -using REALPIPEHANDLE = HANDLE; +using REALPIPEHANDLE = HANDLE; #define INVALID_REALPIPEHANDLE INVALID_HANDLE_VALUE class TRealPipeHandle @@ -183,7 +183,7 @@ private: #else using TRealPipeHandle = TPipeHandle; -using REALPIPEHANDLE = PIPEHANDLE; +using REALPIPEHANDLE = PIPEHANDLE; #define INVALID_REALPIPEHANDLE INVALID_PIPEHANDLE #endif @@ -756,7 +756,7 @@ void TShellCommand::TImpl::OnFork(TPipes& pipes, sigset_t oldmask, char* const* #endif void TShellCommand::TImpl::Run() { - Y_ENSURE(AtomicGet(ExecutionStatus) != SHELL_RUNNING, TStringBuf("Process is already running")); + Y_ENSURE(AtomicGet(ExecutionStatus) != SHELL_RUNNING, TStringBuf("Process is already running")); // Prepare I/O streams CollectedOutput.clear(); CollectedError.clear(); diff --git a/util/system/sigset.h b/util/system/sigset.h index 8dd02fd817..9fa5a9dfe9 100644 --- a/util/system/sigset.h +++ b/util/system/sigset.h @@ -12,7 +12,7 @@ #define SIG_UNBLOCK 2 #define SIG_SETMASK 3 -using sigset_t = ui32; +using sigset_t = ui32; #else #error not supported yet diff --git a/util/system/src_root_ut.cpp b/util/system/src_root_ut.cpp index e9a675eb9a..a77c9ce89c 100644 --- a/util/system/src_root_ut.cpp +++ b/util/system/src_root_ut.cpp @@ -13,7 +13,7 @@ Y_UNIT_TEST_SUITE(TestSourceRoot) { Y_UNIT_TEST(TestPrivateChopPrefixRoutine) { static constexpr const char str[] = ":\0:\0: It's unlikely that this string has an ARCADIA_ROOT as its prefix :\0:\0:"; static constexpr const auto strStaticBuf = STATIC_BUF(str); - UNIT_ASSERT_VALUES_EQUAL(TStringBuf(str, sizeof(str) - 1), ::NPrivate::StripRoot(strStaticBuf).As<TStringBuf>()); + UNIT_ASSERT_VALUES_EQUAL(TStringBuf(str, sizeof(str) - 1), ::NPrivate::StripRoot(strStaticBuf).As<TStringBuf>()); UNIT_ASSERT_VALUES_EQUAL(0, ::NPrivate::RootPrefixLength(strStaticBuf)); static_assert(::NPrivate::IsProperPrefix(STATIC_BUF("foo"), STATIC_BUF("foobar")), R"(IsProperPrefix("foo", "foobar") failed)"); diff --git a/util/system/sysstat.h b/util/system/sysstat.h index b7c424c11b..2d09f10c18 100644 --- a/util/system/sysstat.h +++ b/util/system/sysstat.h @@ -23,9 +23,9 @@ int Chmod(const char* fname, int mode); int Umask(int mode); -static constexpr int MODE0777 = (S_IRWXU | S_IRWXG | S_IRWXO); -static constexpr int MODE0775 = (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); -static constexpr int MODE0755 = (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); +static constexpr int MODE0777 = (S_IRWXU | S_IRWXG | S_IRWXO); +static constexpr int MODE0775 = (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); +static constexpr int MODE0755 = (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); int Mkdir(const char* path, int mode); diff --git a/util/system/user.cpp b/util/system/user.cpp index 83e89ea0a8..cc3ec171ee 100644 --- a/util/system/user.cpp +++ b/util/system/user.cpp @@ -41,7 +41,7 @@ TString GetUsername() { return TString(pwd->pw_name); } - ythrow TSystemError() << TStringBuf(" getpwuid failed"); + ythrow TSystemError() << TStringBuf(" getpwuid failed"); #else passwd pwd; passwd* tmpPwd; diff --git a/util/system/yassert.h b/util/system/yassert.h index 529823440c..e95a792095 100644 --- a/util/system/yassert.h +++ b/util/system/yassert.h @@ -100,12 +100,12 @@ namespace NPrivate { if (Y_UNLIKELY(!(expr))) { \ ::NPrivate::Panic(__SOURCE_FILE_IMPL__, __LINE__, __FUNCTION__, #expr, " " __VA_ARGS__); \ } \ - } while (false) + } while (false) #define Y_FAIL(...) \ do { \ ::NPrivate::Panic(__SOURCE_FILE_IMPL__, __LINE__, __FUNCTION__, nullptr, " " __VA_ARGS__); \ - } while (false) + } while (false) #ifndef NDEBUG /// Assert that depend on NDEBUG macro and outputs message like printf diff --git a/util/thread/factory.cpp b/util/thread/factory.cpp index 48e898f32d..150c4aa783 100644 --- a/util/thread/factory.cpp +++ b/util/thread/factory.cpp @@ -56,7 +56,7 @@ namespace { : Func(func) { } - void DoExecute() override { + void DoExecute() override { THolder<TThreadFactoryFuncObj> self(this); Func(); } diff --git a/util/thread/pool.cpp b/util/thread/pool.cpp index 05fad02e9b..e35fde4a1c 100644 --- a/util/thread/pool.cpp +++ b/util/thread/pool.cpp @@ -350,7 +350,7 @@ size_t TThreadPool::GetMaxQueueSize() const noexcept { } bool TThreadPool::Add(IObjectInQueue* obj) { - Y_ENSURE_EX(Impl_.Get(), TThreadPoolException() << TStringBuf("mtp queue not started")); + Y_ENSURE_EX(Impl_.Get(), TThreadPoolException() << TStringBuf("mtp queue not started")); if (Impl_->NeedRestart()) { Start(Impl_->GetThreadCountExpected(), Impl_->GetMaxQueueSize()); @@ -455,7 +455,7 @@ public: Obj_ = obj; - Y_ENSURE_EX(!AllDone_, TThreadPoolException() << TStringBuf("adding to a stopped queue")); + Y_ENSURE_EX(!AllDone_, TThreadPoolException() << TStringBuf("adding to a stopped queue")); } CondReady_.Signal(); @@ -566,7 +566,7 @@ DEFINE_THREAD_POOL_CTORS(TSimpleThreadPool) TAdaptiveThreadPool::~TAdaptiveThreadPool() = default; bool TAdaptiveThreadPool::Add(IObjectInQueue* obj) { - Y_ENSURE_EX(Impl_.Get(), TThreadPoolException() << TStringBuf("mtp queue not started")); + Y_ENSURE_EX(Impl_.Get(), TThreadPoolException() << TStringBuf("mtp queue not started")); Impl_->Add(obj); @@ -590,7 +590,7 @@ size_t TAdaptiveThreadPool::Size() const noexcept { } void TAdaptiveThreadPool::SetMaxIdleTime(TDuration interval) { - Y_ENSURE_EX(Impl_.Get(), TThreadPoolException() << TStringBuf("mtp queue not started")); + Y_ENSURE_EX(Impl_.Get(), TThreadPoolException() << TStringBuf("mtp queue not started")); Impl_->SetMaxIdleTime(interval); } @@ -604,7 +604,7 @@ TSimpleThreadPool::~TSimpleThreadPool() { } bool TSimpleThreadPool::Add(IObjectInQueue* obj) { - Y_ENSURE_EX(Slave_.Get(), TThreadPoolException() << TStringBuf("mtp queue not started")); + Y_ENSURE_EX(Slave_.Get(), TThreadPoolException() << TStringBuf("mtp queue not started")); return Slave_->Add(obj); } @@ -660,11 +660,11 @@ namespace { } void IThreadPool::SafeAdd(IObjectInQueue* obj) { - Y_ENSURE_EX(Add(obj), TThreadPoolException() << TStringBuf("can not add object to queue")); + Y_ENSURE_EX(Add(obj), TThreadPoolException() << TStringBuf("can not add object to queue")); } void IThreadPool::SafeAddAndOwn(THolder<IObjectInQueue> obj) { - Y_ENSURE_EX(AddAndOwn(std::move(obj)), TThreadPoolException() << TStringBuf("can not add to queue and own")); + Y_ENSURE_EX(AddAndOwn(std::move(obj)), TThreadPoolException() << TStringBuf("can not add to queue and own")); } bool IThreadPool::AddAndOwn(THolder<IObjectInQueue> obj) { diff --git a/util/thread/pool.h b/util/thread/pool.h index d1ea3a67cb..3f9c2bbe14 100644 --- a/util/thread/pool.h +++ b/util/thread/pool.h @@ -150,7 +150,7 @@ public: template <class T> void SafeAddFunc(T&& func) { - Y_ENSURE_EX(AddFunc(std::forward<T>(func)), TThreadPoolException() << TStringBuf("can not add function to queue")); + Y_ENSURE_EX(AddFunc(std::forward<T>(func)), TThreadPoolException() << TStringBuf("can not add function to queue")); } void SafeAddAndOwn(THolder<IObjectInQueue> obj); diff --git a/util/ysaveload.h b/util/ysaveload.h index 02efb4049b..6d894a0ac6 100644 --- a/util/ysaveload.h +++ b/util/ysaveload.h @@ -64,7 +64,7 @@ static inline void LoadPodType(IInputStream* rh, T& t) { const size_t res = rh->Load(&t, sizeof(T)); if (Y_UNLIKELY(res != sizeof(T))) { - ::NPrivate::ThrowLoadEOFException(sizeof(T), res, TStringBuf("pod type")); + ::NPrivate::ThrowLoadEOFException(sizeof(T), res, TStringBuf("pod type")); } } @@ -79,7 +79,7 @@ static inline void LoadPodArray(IInputStream* rh, T* arr, size_t count) { const size_t res = rh->Load(arr, len); if (Y_UNLIKELY(res != len)) { - ::NPrivate::ThrowLoadEOFException(len, res, TStringBuf("pod array")); + ::NPrivate::ThrowLoadEOFException(len, res, TStringBuf("pod array")); } } @@ -453,10 +453,10 @@ public: static void Load(IInputStream* rh, TBuffer& buf); }; -template <class TSetOrMap, class TValue> -class TSetSerializerInserterBase { +template <class TSetOrMap, class TValue> +class TSetSerializerInserterBase { public: - inline TSetSerializerInserterBase(TSetOrMap& s) + inline TSetSerializerInserterBase(TSetOrMap& s) : S_(s) { S_.clear(); @@ -466,29 +466,29 @@ public: S_.insert(v); } -protected: - TSetOrMap& S_; +protected: + TSetOrMap& S_; }; -template <class TSetOrMap, class TValue, bool sorted> +template <class TSetOrMap, class TValue, bool sorted> class TSetSerializerInserter: public TSetSerializerInserterBase<TSetOrMap, TValue> { - using TBase = TSetSerializerInserterBase<TSetOrMap, TValue>; + using TBase = TSetSerializerInserterBase<TSetOrMap, TValue>; -public: - inline TSetSerializerInserter(TSetOrMap& s, size_t cnt) - : TBase(s) - { +public: + inline TSetSerializerInserter(TSetOrMap& s, size_t cnt) + : TBase(s) + { Y_UNUSED(cnt); - } -}; - + } +}; + template <class TSetType, class TValue> class TSetSerializerInserter<TSetType, TValue, true>: public TSetSerializerInserterBase<TSetType, TValue> { using TBase = TSetSerializerInserterBase<TSetType, TValue>; public: inline TSetSerializerInserter(TSetType& s, size_t cnt) - : TBase(s) + : TBase(s) { Y_UNUSED(cnt); P_ = this->S_.begin(); @@ -502,19 +502,19 @@ private: typename TSetType::iterator P_; }; -template <class T1, class T2, class T3, class T4, class T5, class TValue> +template <class T1, class T2, class T3, class T4, class T5, class TValue> class TSetSerializerInserter<THashMap<T1, T2, T3, T4, T5>, TValue, false>: public TSetSerializerInserterBase<THashMap<T1, T2, T3, T4, T5>, TValue> { using TMapType = THashMap<T1, T2, T3, T4, T5>; using TBase = TSetSerializerInserterBase<TMapType, TValue>; -public: +public: inline TSetSerializerInserter(TMapType& m, size_t cnt) - : TBase(m) - { + : TBase(m) + { m.reserve(cnt); - } -}; - + } +}; + template <class T1, class T2, class T3, class T4, class T5, class TValue> class TSetSerializerInserter<THashMultiMap<T1, T2, T3, T4, T5>, TValue, false>: public TSetSerializerInserterBase<THashMultiMap<T1, T2, T3, T4, T5>, TValue> { using TMapType = THashMultiMap<T1, T2, T3, T4, T5>; @@ -528,19 +528,19 @@ public: } }; -template <class T1, class T2, class T3, class T4, class TValue> +template <class T1, class T2, class T3, class T4, class TValue> class TSetSerializerInserter<THashSet<T1, T2, T3, T4>, TValue, false>: public TSetSerializerInserterBase<THashSet<T1, T2, T3, T4>, TValue> { using TSetType = THashSet<T1, T2, T3, T4>; using TBase = TSetSerializerInserterBase<TSetType, TValue>; -public: +public: inline TSetSerializerInserter(TSetType& s, size_t cnt) - : TBase(s) - { + : TBase(s) + { s.reserve(cnt); - } -}; - + } +}; + template <class TSetType, class TValue, bool sorted> class TSetSerializerBase { public: |