diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /util | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r-- | util/datetime/base.cpp | 72 | ||||
-rw-r--r-- | util/datetime/base.h | 80 | ||||
-rw-r--r-- | util/folder/dirut.cpp | 2 | ||||
-rw-r--r-- | util/generic/array_ref_ut.cpp | 8 | ||||
-rw-r--r-- | util/generic/flags_ut.cpp | 2 | ||||
-rw-r--r-- | util/generic/fwd.h | 4 | ||||
-rw-r--r-- | util/generic/strbase.h | 82 | ||||
-rw-r--r-- | util/generic/string.cpp | 32 | ||||
-rw-r--r-- | util/generic/string_ut.cpp | 8 | ||||
-rw-r--r-- | util/generic/vector.pxd | 36 | ||||
-rw-r--r-- | util/generic/ylimits.h | 102 | ||||
-rw-r--r-- | util/generic/ylimits_ut.cpp | 30 | ||||
-rw-r--r-- | util/memory/pool.h | 10 | ||||
-rw-r--r-- | util/stream/direct_io.cpp | 8 | ||||
-rw-r--r-- | util/stream/direct_io.h | 2 | ||||
-rw-r--r-- | util/stream/output.cpp | 14 | ||||
-rw-r--r-- | util/stream/str.cpp | 4 | ||||
-rw-r--r-- | util/stream/str.h | 4 | ||||
-rw-r--r-- | util/string/cast.h | 8 | ||||
-rw-r--r-- | util/string/escape.h | 2 | ||||
-rw-r--r-- | util/string/join.h | 2 | ||||
-rw-r--r-- | util/string/split.h | 4 | ||||
-rw-r--r-- | util/string/vector.cpp | 2 | ||||
-rw-r--r-- | util/system/file.cpp | 2 | ||||
-rw-r--r-- | util/system/mlock.cpp | 6 | ||||
-rw-r--r-- | util/system/mlock.h | 6 | ||||
-rw-r--r-- | util/system/user.cpp | 12 | ||||
-rw-r--r-- | util/thread/lfstack.h | 10 |
28 files changed, 277 insertions, 277 deletions
diff --git a/util/datetime/base.cpp b/util/datetime/base.cpp index e3e4632714..38ecc3ab96 100644 --- a/util/datetime/base.cpp +++ b/util/datetime/base.cpp @@ -97,9 +97,9 @@ namespace { << Pad<2>(theTm.tm_hour) << ':' << Pad<2>(theTm.tm_min) << ':' << Pad<2>(theTm.tm_sec); } - template <bool PrintUpToSeconds, bool iso> - void WritePrintableLocalTimeToStream(IOutputStream& os, const ::NPrivate::TPrintableLocalTime<PrintUpToSeconds, iso>& timeToPrint) { - const TInstant& momentToPrint = timeToPrint.MomentToPrint; + template <bool PrintUpToSeconds, bool iso> + void WritePrintableLocalTimeToStream(IOutputStream& os, const ::NPrivate::TPrintableLocalTime<PrintUpToSeconds, iso>& timeToPrint) { + const TInstant& momentToPrint = timeToPrint.MomentToPrint; struct tm localTime; momentToPrint.LocalTime(&localTime); WriteTmToStream(os, localTime); @@ -124,11 +124,11 @@ namespace { } else { os << '+'; } - os << Pad<2>(utcOffsetInMinutes / 60); - if (iso) { - os << ':'; - } - os << Pad<2>(utcOffsetInMinutes % 60); + os << Pad<2>(utcOffsetInMinutes / 60); + if (iso) { + os << ':'; + } + os << Pad<2>(utcOffsetInMinutes % 60); } } } @@ -163,16 +163,16 @@ void Out<::NPrivate::TPrintableLocalTime<false, true>>(IOutputStream& os, TTypeT WritePrintableLocalTimeToStream(os, localTime); } -template <> +template <> void Out<::NPrivate::TPrintableLocalTime<true, false>>(IOutputStream& os, TTypeTraits<::NPrivate::TPrintableLocalTime<true, false>>::TFuncParam localTime) { - WritePrintableLocalTimeToStream(os, localTime); -} - -template <> + WritePrintableLocalTimeToStream(os, localTime); +} + +template <> void Out<::NPrivate::TPrintableLocalTime<true, true>>(IOutputStream& os, TTypeTraits<::NPrivate::TPrintableLocalTime<true, true>>::TFuncParam localTime) { - WritePrintableLocalTimeToStream(os, localTime); -} - + WritePrintableLocalTimeToStream(os, localTime); +} + TString TDuration::ToString() const { return ::ToString(*this); } @@ -194,10 +194,10 @@ TString TInstant::ToStringUpToSeconds() const { return TString(buf, len); } -TString TInstant::ToIsoStringLocal() const { - return ::ToString(FormatIsoLocal(*this)); -} - +TString TInstant::ToIsoStringLocal() const { + return ::ToString(FormatIsoLocal(*this)); +} + TString TInstant::ToStringLocal() const { return ::ToString(FormatLocal(*this)); } @@ -206,10 +206,10 @@ TString TInstant::ToRfc822StringLocal() const { return FormatLocalTime("%a, %d %b %Y %H:%M:%S %Z"); } -TString TInstant::ToIsoStringLocalUpToSeconds() const { - return ::ToString(FormatIsoLocalUpToSeconds(*this)); -} - +TString TInstant::ToIsoStringLocalUpToSeconds() const { + return ::ToString(FormatIsoLocalUpToSeconds(*this)); +} + TString TInstant::ToStringLocalUpToSeconds() const { return ::ToString(FormatLocalUpToSeconds(*this)); } @@ -226,22 +226,22 @@ TString TInstant::FormatGmTime(const char* format) const noexcept { return Strftime(format, &theTm); } -::NPrivate::TPrintableLocalTime<false, true> FormatIsoLocal(TInstant instant) { - return ::NPrivate::TPrintableLocalTime<false, true>(instant); +::NPrivate::TPrintableLocalTime<false, true> FormatIsoLocal(TInstant instant) { + return ::NPrivate::TPrintableLocalTime<false, true>(instant); +} + +::NPrivate::TPrintableLocalTime<false, false> FormatLocal(TInstant instant) { + return ::NPrivate::TPrintableLocalTime<false, false>(instant); +} + +::NPrivate::TPrintableLocalTime<true, true> FormatIsoLocalUpToSeconds(TInstant instant) { + return ::NPrivate::TPrintableLocalTime<true, true>(instant); } -::NPrivate::TPrintableLocalTime<false, false> FormatLocal(TInstant instant) { - return ::NPrivate::TPrintableLocalTime<false, false>(instant); +::NPrivate::TPrintableLocalTime<true, false> FormatLocalUpToSeconds(TInstant instant) { + return ::NPrivate::TPrintableLocalTime<true, false>(instant); } -::NPrivate::TPrintableLocalTime<true, true> FormatIsoLocalUpToSeconds(TInstant instant) { - return ::NPrivate::TPrintableLocalTime<true, true>(instant); -} - -::NPrivate::TPrintableLocalTime<true, false> FormatLocalUpToSeconds(TInstant instant) { - return ::NPrivate::TPrintableLocalTime<true, false>(instant); -} - void Sleep(TDuration duration) { NanoSleep(duration.NanoSeconds()); } diff --git a/util/datetime/base.h b/util/datetime/base.h index 82b95c684c..5e902b8f63 100644 --- a/util/datetime/base.h +++ b/util/datetime/base.h @@ -468,17 +468,17 @@ public: /** * Formats the instant using the system time zone, with microsecond precision. * - * @returns An ISO 8601 / RFC 3339 formatted string, - * e.g. '2015-11-22T04:30:27.991669+05:00'. + * @returns An ISO 8601 / RFC 3339 formatted string, + * e.g. '2015-11-22T04:30:27.991669+05:00'. + */ + TString ToIsoStringLocal() const; + + /** + * Formats the instant using the system time zone, with microsecond precision. + * + * @returns A semi-ISO 8601 formatted string with timezone without colon, + * e.g. '2015-11-22T04:30:27.991669+0500'. */ - TString ToIsoStringLocal() const; - - /** - * Formats the instant using the system time zone, with microsecond precision. - * - * @returns A semi-ISO 8601 formatted string with timezone without colon, - * e.g. '2015-11-22T04:30:27.991669+0500'. - */ TString ToStringLocal() const; /** @@ -491,17 +491,17 @@ public: /** * Formats the instant using the system time zone, with second precision. * - * @returns An ISO 8601 / RFC 3339 formatted string, - * e.g. '2015-11-22T04:30:27+05:00'. + * @returns An ISO 8601 / RFC 3339 formatted string, + * e.g. '2015-11-22T04:30:27+05:00'. + */ + TString ToIsoStringLocalUpToSeconds() const; + + /** + * Formats the instant using the system time zone, with second precision. + * + * @returns A semi-ISO 8601 formatted string with timezone without colon, + * e.g. '2015-11-22T04:30:27+0500'. */ - TString ToIsoStringLocalUpToSeconds() const; - - /** - * Formats the instant using the system time zone, with second precision. - * - * @returns A semi-ISO 8601 formatted string with timezone without colon, - * e.g. '2015-11-22T04:30:27+0500'. - */ TString ToStringLocalUpToSeconds() const; TString FormatLocalTime(const char* format) const noexcept; @@ -567,7 +567,7 @@ struct THash<TInstant> { }; namespace NPrivate { - template <bool PrintUpToSeconds, bool iso> + template <bool PrintUpToSeconds, bool iso> struct TPrintableLocalTime { TInstant MomentToPrint; @@ -591,14 +591,14 @@ namespace NPrivate { * TInstant::ToString*() functions. */ ///@{ -/// @see TInstant::ToIsoStringLocal() -::NPrivate::TPrintableLocalTime<false, true> FormatIsoLocal(TInstant instant); +/// @see TInstant::ToIsoStringLocal() +::NPrivate::TPrintableLocalTime<false, true> FormatIsoLocal(TInstant instant); /// @see TInstant::ToStringLocal() -::NPrivate::TPrintableLocalTime<false, false> FormatLocal(TInstant instant); -/// @see TInstant::ToIsoStringLocalUpToSeconds() -::NPrivate::TPrintableLocalTime<true, true> FormatIsoLocalUpToSeconds(TInstant instant); +::NPrivate::TPrintableLocalTime<false, false> FormatLocal(TInstant instant); +/// @see TInstant::ToIsoStringLocalUpToSeconds() +::NPrivate::TPrintableLocalTime<true, true> FormatIsoLocalUpToSeconds(TInstant instant); /// @see TInstant::ToStringLocalUpToSeconds() -::NPrivate::TPrintableLocalTime<true, false> FormatLocalUpToSeconds(TInstant instant); +::NPrivate::TPrintableLocalTime<true, false> FormatLocalUpToSeconds(TInstant instant); ///@} template <class S> @@ -772,25 +772,25 @@ constexpr TInstant operator-(const TInstant& l, const std::chrono::duration<T, T } template <class T> -inline TDuration operator*(TDuration d, T t) noexcept { +inline TDuration operator*(TDuration d, T t) noexcept { Y_ASSERT(t >= T()); Y_ASSERT(t == T() || Max<TDuration::TValue>() / t >= d.GetValue()); return TDuration::FromValue(d.GetValue() * t); } -template <> -inline TDuration operator*(TDuration d, double t) noexcept { - Y_ASSERT(t >= 0 && MaxFloor<TDuration::TValue>() >= d.GetValue() * t); - return TDuration::FromValue(d.GetValue() * t); -} - -template <> -inline TDuration operator*(TDuration d, float t) noexcept { - return d * static_cast<double>(t); -} - +template <> +inline TDuration operator*(TDuration d, double t) noexcept { + Y_ASSERT(t >= 0 && MaxFloor<TDuration::TValue>() >= d.GetValue() * t); + return TDuration::FromValue(d.GetValue() * t); +} + +template <> +inline TDuration operator*(TDuration d, float t) noexcept { + return d * static_cast<double>(t); +} + template <class T> -inline TDuration operator*(T t, TDuration d) noexcept { +inline TDuration operator*(T t, TDuration d) noexcept { return d * t; } diff --git a/util/folder/dirut.cpp b/util/folder/dirut.cpp index a2a467d191..ffc9b09f96 100644 --- a/util/folder/dirut.cpp +++ b/util/folder/dirut.cpp @@ -553,7 +553,7 @@ TString GetBaseName(const TString& path) { } static bool IsAbsolutePath(const char* str) { - return str && TPathSplitTraitsLocal::IsAbsolutePath(TStringBuf(str, NStringPrivate::GetStringLengthWithLimit(str, 3))); + return str && TPathSplitTraitsLocal::IsAbsolutePath(TStringBuf(str, NStringPrivate::GetStringLengthWithLimit(str, 3))); } int ResolvePath(const char* rel, const char* abs, char res[/*MAXPATHLEN*/], bool isdir) { diff --git a/util/generic/array_ref_ut.cpp b/util/generic/array_ref_ut.cpp index 1fcae731e7..4c8eaf7135 100644 --- a/util/generic/array_ref_ut.cpp +++ b/util/generic/array_ref_ut.cpp @@ -196,15 +196,15 @@ Y_UNIT_TEST_SUITE(TestArrayRef) { } Y_UNIT_TEST(TestSlice) { - const int a0[] = {1, 2, 3}; - TArrayRef<const int> r0(a0); + const int a0[] = {1, 2, 3}; + TArrayRef<const int> r0(a0); TArrayRef<const int> s0 = r0.Slice(2); UNIT_ASSERT_VALUES_EQUAL(s0.size(), 1); UNIT_ASSERT_VALUES_EQUAL(s0[0], 3); - const int a1[] = {1, 2, 3, 4}; - TArrayRef<const int> r1(a1); + const int a1[] = {1, 2, 3, 4}; + TArrayRef<const int> r1(a1); TArrayRef<const int> s1 = r1.Slice(2, 1); UNIT_ASSERT_VALUES_EQUAL(s1.size(), 1); diff --git a/util/generic/flags_ut.cpp b/util/generic/flags_ut.cpp index 4ce32e1cc9..5377c6a058 100644 --- a/util/generic/flags_ut.cpp +++ b/util/generic/flags_ut.cpp @@ -79,7 +79,7 @@ Y_UNIT_TEST_SUITE(TFlagsTest) { f = ETest1(0); ETest1 ff(0); - ff = 0; + ff = 0; } Y_UNIT_TEST(TestOutput) { diff --git a/util/generic/fwd.h b/util/generic/fwd.h index 08dc6325e0..5cc2da40e5 100644 --- a/util/generic/fwd.h +++ b/util/generic/fwd.h @@ -4,14 +4,14 @@ #include <stlfwd> -template <typename TCharType, typename TTraits = std::char_traits<TCharType>> +template <typename TCharType, typename TTraits = std::char_traits<TCharType>> class TBasicString; using TString = TBasicString<char>; using TUtf16String = TBasicString<wchar16>; using TUtf32String = TBasicString<wchar32>; -template <typename TCharType, typename TTraits = std::char_traits<TCharType>> +template <typename TCharType, typename TTraits = std::char_traits<TCharType>> class TBasicStringBuf; using TStringBuf = TBasicStringBuf<char>; diff --git a/util/generic/strbase.h b/util/generic/strbase.h index 5cdc89fbbc..ab39fc7537 100644 --- a/util/generic/strbase.h +++ b/util/generic/strbase.h @@ -1,40 +1,40 @@ #pragma once -// Some of these includes are just a legacy from previous implementation. -// We don't need them here, but removing them is tricky because it breaks all -// kinds of builds downstream -#include "mem_copy.h" -#include "ptr.h" -#include "utility.h" - -#include <util/charset/unidata.h> -#include <util/system/platform.h> +// Some of these includes are just a legacy from previous implementation. +// We don't need them here, but removing them is tricky because it breaks all +// kinds of builds downstream +#include "mem_copy.h" +#include "ptr.h" +#include "utility.h" + +#include <util/charset/unidata.h> +#include <util/system/platform.h> #include <util/system/yassert.h> -#include <contrib/libs/libc_compat/string.h> - -#include <cctype> -#include <cstring> -#include <string> -#include <string_view> - -namespace NStringPrivate { - template <class TCharType> - size_t GetStringLengthWithLimit(const TCharType* s, size_t maxlen) { - Y_ASSERT(s); - size_t i = 0; - for (; i != maxlen && s[i]; ++i) - ; - return i; - } - - inline size_t GetStringLengthWithLimit(const char* s, size_t maxlen) { - Y_ASSERT(s); - return strnlen(s, maxlen); - } -} - -template <typename TDerived, typename TCharType, typename TTraitsType = std::char_traits<TCharType>> +#include <contrib/libs/libc_compat/string.h> + +#include <cctype> +#include <cstring> +#include <string> +#include <string_view> + +namespace NStringPrivate { + template <class TCharType> + size_t GetStringLengthWithLimit(const TCharType* s, size_t maxlen) { + Y_ASSERT(s); + size_t i = 0; + for (; i != maxlen && s[i]; ++i) + ; + return i; + } + + inline size_t GetStringLengthWithLimit(const char* s, size_t maxlen) { + Y_ASSERT(s); + return strnlen(s, maxlen); + } +} + +template <typename TDerived, typename TCharType, typename TTraitsType = std::char_traits<TCharType>> class TStringBase { using TStringView = std::basic_string_view<TCharType>; using TStringViewWithTraits = std::basic_string_view<TCharType, TTraitsType>; @@ -536,18 +536,18 @@ public: return AsStringView().find_last_of(set, pos, n); } - inline size_t find_last_not_of(TCharType c, size_t pos = npos) const noexcept { + inline size_t find_last_not_of(TCharType c, size_t pos = npos) const noexcept { return AsStringView().find_last_not_of(c, pos); - } - + } + inline size_t find_last_not_of(const TStringView set, size_t pos = npos) const noexcept { return find_last_not_of(set.data(), pos, set.length()); - } - - inline size_t find_last_not_of(const TCharType* set, size_t pos, size_t n) const noexcept { + } + + inline size_t find_last_not_of(const TCharType* set, size_t pos, size_t n) const noexcept { return AsStringView().find_last_not_of(set, pos, n); - } - + } + inline size_t copy(TCharType* pc, size_t n, size_t pos) const { if (pos > Len()) { throw std::out_of_range("TStringBase::copy"); diff --git a/util/generic/string.cpp b/util/generic/string.cpp index 1dc9a8b445..3c655f1f66 100644 --- a/util/generic/string.cpp +++ b/util/generic/string.cpp @@ -19,17 +19,17 @@ std::istream& operator>>(std::istream& is, TString& s) { } template <> -bool TBasicString<char, std::char_traits<char>>::to_lower(size_t pos, size_t n) { +bool TBasicString<char, std::char_traits<char>>::to_lower(size_t pos, size_t n) { return Transform([](size_t, char c) { return AsciiToLower(c); }, pos, n); } template <> -bool TBasicString<char, std::char_traits<char>>::to_upper(size_t pos, size_t n) { +bool TBasicString<char, std::char_traits<char>>::to_upper(size_t pos, size_t n) { return Transform([](size_t, char c) { return AsciiToUpper(c); }, pos, n); } template <> -bool TBasicString<char, std::char_traits<char>>::to_title(size_t pos, size_t n) { +bool TBasicString<char, std::char_traits<char>>::to_title(size_t pos, size_t n) { if (n == 0) { return false; } @@ -39,7 +39,7 @@ bool TBasicString<char, std::char_traits<char>>::to_title(size_t pos, size_t n) template <> TUtf16String& -TBasicString<wchar16, std::char_traits<wchar16>>::AppendAscii(const ::TStringBuf& s) { +TBasicString<wchar16, std::char_traits<wchar16>>::AppendAscii(const ::TStringBuf& s) { ReserveAndResize(size() + s.size()); auto dst = begin() + size() - s.size(); @@ -53,7 +53,7 @@ TBasicString<wchar16, std::char_traits<wchar16>>::AppendAscii(const ::TStringBuf template <> TUtf16String& -TBasicString<wchar16, std::char_traits<wchar16>>::AppendUtf8(const ::TStringBuf& s) { +TBasicString<wchar16, std::char_traits<wchar16>>::AppendUtf8(const ::TStringBuf& s) { size_t oldSize = size(); ReserveAndResize(size() + s.size() * 4); size_t written = 0; @@ -67,23 +67,23 @@ TBasicString<wchar16, std::char_traits<wchar16>>::AppendUtf8(const ::TStringBuf& } template <> -bool TBasicString<wchar16, std::char_traits<wchar16>>::to_lower(size_t pos, size_t n) { +bool TBasicString<wchar16, std::char_traits<wchar16>>::to_lower(size_t pos, size_t n) { return ToLower(*this, pos, n); } template <> -bool TBasicString<wchar16, std::char_traits<wchar16>>::to_upper(size_t pos, size_t n) { +bool TBasicString<wchar16, std::char_traits<wchar16>>::to_upper(size_t pos, size_t n) { return ToUpper(*this, pos, n); } template <> -bool TBasicString<wchar16, std::char_traits<wchar16>>::to_title(size_t pos, size_t n) { +bool TBasicString<wchar16, std::char_traits<wchar16>>::to_title(size_t pos, size_t n) { return ToTitle(*this, pos, n); } template <> TUtf32String& -TBasicString<wchar32, std::char_traits<wchar32>>::AppendAscii(const ::TStringBuf& s) { +TBasicString<wchar32, std::char_traits<wchar32>>::AppendAscii(const ::TStringBuf& s) { ReserveAndResize(size() + s.size()); auto dst = begin() + size() - s.size(); @@ -96,8 +96,8 @@ TBasicString<wchar32, std::char_traits<wchar32>>::AppendAscii(const ::TStringBuf } template <> -TBasicString<char, std::char_traits<char>>& -TBasicString<char, std::char_traits<char>>::AppendUtf16(const ::TWtringBuf& s) { +TBasicString<char, std::char_traits<char>>& +TBasicString<char, std::char_traits<char>>::AppendUtf16(const ::TWtringBuf& s) { const size_t oldSize = size(); ReserveAndResize(size() + WideToUTF8BufferSize(s.size())); @@ -111,7 +111,7 @@ TBasicString<char, std::char_traits<char>>::AppendUtf16(const ::TWtringBuf& s) { template <> TUtf32String& -TBasicString<wchar32, std::char_traits<wchar32>>::AppendUtf8(const ::TStringBuf& s) { +TBasicString<wchar32, std::char_traits<wchar32>>::AppendUtf8(const ::TStringBuf& s) { size_t oldSize = size(); ReserveAndResize(size() + s.size() * 4); size_t written = 0; @@ -126,7 +126,7 @@ TBasicString<wchar32, std::char_traits<wchar32>>::AppendUtf8(const ::TStringBuf& template <> TUtf32String& -TBasicString<wchar32, std::char_traits<wchar32>>::AppendUtf16(const ::TWtringBuf& s) { +TBasicString<wchar32, std::char_traits<wchar32>>::AppendUtf16(const ::TWtringBuf& s) { size_t oldSize = size(); ReserveAndResize(size() + s.size() * 2); @@ -141,16 +141,16 @@ TBasicString<wchar32, std::char_traits<wchar32>>::AppendUtf16(const ::TWtringBuf } template <> -bool TBasicString<wchar32, std::char_traits<wchar32>>::to_lower(size_t pos, size_t n) { +bool TBasicString<wchar32, std::char_traits<wchar32>>::to_lower(size_t pos, size_t n) { return ToLower(*this, pos, n); } template <> -bool TBasicString<wchar32, std::char_traits<wchar32>>::to_upper(size_t pos, size_t n) { +bool TBasicString<wchar32, std::char_traits<wchar32>>::to_upper(size_t pos, size_t n) { return ToUpper(*this, pos, n); } template <> -bool TBasicString<wchar32, std::char_traits<wchar32>>::to_title(size_t pos, size_t n) { +bool TBasicString<wchar32, std::char_traits<wchar32>>::to_title(size_t pos, size_t n) { return ToTitle(*this, pos, n); } diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp index 4d83037c06..ac82e9091d 100644 --- a/util/generic/string_ut.cpp +++ b/util/generic/string_ut.cpp @@ -618,7 +618,7 @@ protected: UNIT_ASSERT(test.rfind(*Data.a(), 1) == 0); UNIT_ASSERT(test.rfind(*Data.a(), 0) == 0); } -#endif +#endif void find_last_not_of() { // 21.3.6.6 TStringType s(Data_.one_two_three_one_two_three()); @@ -641,7 +641,7 @@ protected: UNIT_ASSERT(test.find_last_not_of(*Data_.a(), 0) == TStringType::npos); UNIT_ASSERT(test.find_last_not_of(*Data_.b(), 0) == 0); } -#if 0 +#if 0 void replace() { // This test case is for the non template basic_TString::replace method, // this is why we play with the const iterators and reference to guaranty @@ -1135,7 +1135,7 @@ public: UNIT_TEST(rfind); UNIT_TEST(replace); #endif - UNIT_TEST(find_last_not_of); + UNIT_TEST(find_last_not_of); UNIT_TEST_SUITE_END(); }; @@ -1171,7 +1171,7 @@ public: UNIT_TEST(rfind); UNIT_TEST(replace); #endif - UNIT_TEST(find_last_not_of); + UNIT_TEST(find_last_not_of); UNIT_TEST_SUITE_END(); }; diff --git a/util/generic/vector.pxd b/util/generic/vector.pxd index aa686bccc6..99dde95d48 100644 --- a/util/generic/vector.pxd +++ b/util/generic/vector.pxd @@ -26,11 +26,11 @@ cdef extern from "<util/generic/vector.h>" nogil: bint operator<=(reverse_iterator) bint operator>=(reverse_iterator) - cppclass const_iterator(iterator): - pass + cppclass const_iterator(iterator): + pass - cppclass const_reverse_iterator(reverse_iterator): - pass + cppclass const_reverse_iterator(reverse_iterator): + pass TVector() except + TVector(TVector&) except + @@ -45,39 +45,39 @@ cdef extern from "<util/generic/vector.h>" nogil: bint operator>=(TVector&) void assign(size_t, const T&) except + - void assign[input_iterator](input_iterator, input_iterator) except + + void assign[input_iterator](input_iterator, input_iterator) except + - T& at(size_t) except + + T& at(size_t) except + T& operator[](size_t) T& back() iterator begin() - const_iterator const_begin "begin"() + const_iterator const_begin "begin"() size_t capacity() void clear() except + bint empty() iterator end() - const_iterator const_end "end"() + const_iterator const_end "end"() iterator erase(iterator) except + iterator erase(iterator, iterator) except + T& front() - iterator insert(iterator, const T&) except + - void insert(iterator, size_t, const T&) except + - void insert[Iter](iterator, Iter, Iter) except + + iterator insert(iterator, const T&) except + + void insert(iterator, size_t, const T&) except + + void insert[Iter](iterator, Iter, Iter) except + size_t max_size() void pop_back() except + - void push_back(T&) except + + void push_back(T&) except + void emplace_back(...) except + reverse_iterator rbegin() - const_reverse_iterator const_rbegin "rbegin"() + const_reverse_iterator const_rbegin "rbegin"() reverse_iterator rend() - const_reverse_iterator const_rend "rend"() + const_reverse_iterator const_rend "rend"() void reserve(size_t) except + - void resize(size_t) except + - void resize(size_t, T&) except + + void resize(size_t) except + + void resize(size_t, T&) except + size_t size() void swap(TVector&) except + - - # C++11 methods + + # C++11 methods T* data() void shrink_to_fit() except + diff --git a/util/generic/ylimits.h b/util/generic/ylimits.h index 9bc5f4e162..fe42b4dfc0 100644 --- a/util/generic/ylimits.h +++ b/util/generic/ylimits.h @@ -39,54 +39,54 @@ static constexpr ::NPrivate::TMax Max() noexcept { static constexpr ::NPrivate::TMin Min() noexcept { return {}; } - -namespace NPrivate { - template <unsigned long long N> - static constexpr double MaxFloorValue() { - return N; - } - template <unsigned long long N> - static constexpr double MaxCeilValue() { - return N; - } - template <> - constexpr double MaxFloorValue<0x7FFF'FFFF'FFFF'FFFFull>() { - return 9223372036854774784.0; // 0x7FFFFFFFFFFFFC00p0 - } - template <> - constexpr double MaxCeilValue<0x7FFF'FFFF'FFFF'FFFFull>() { - return 9223372036854775808.0; // 0x8000000000000000p0 - } - template <> - constexpr double MaxFloorValue<0xFFFF'FFFF'FFFF'FFFFull>() { - return 18446744073709549568.0; // 0xFFFFFFFFFFFFF800p0 - } - template <> - constexpr double MaxCeilValue<0xFFFF'FFFF'FFFF'FFFFull>() { - return 18446744073709551616.0; // 0x10000000000000000p0 - } -} - -// MaxFloor<T> is the greatest double within the range of T. -// -// 1. If Max<T> is an exact double, MaxFloor<T> = Max<T> = MaxCeil<T>. -// In this case some doubles above MaxFloor<T> cast to T may round -// to Max<T> depending on the rounding mode. -// -// 2. Otherwise Max<T> is between MaxFloor<T> and MaxCeil<T>, and -// MaxFloor<T> is the largest double that does not overflow T. -template <class T> -static constexpr double MaxFloor() noexcept { - return ::NPrivate::MaxFloorValue<Max<T>()>(); -} - -// MaxCeil<T> is the smallest double not lesser than Max<T>. -// -// 1. If Max<T> is an exact double, MaxCeil<T> = Max<T> = MaxFloor<T>. -// -// 2. Otherwise Max<T> is between MaxFloor<T> and MaxCeil<T>, and -// MaxCeil<T> is the smallest double that overflows T. -template <class T> -static constexpr double MaxCeil() noexcept { - return ::NPrivate::MaxCeilValue<Max<T>()>(); -} + +namespace NPrivate { + template <unsigned long long N> + static constexpr double MaxFloorValue() { + return N; + } + template <unsigned long long N> + static constexpr double MaxCeilValue() { + return N; + } + template <> + constexpr double MaxFloorValue<0x7FFF'FFFF'FFFF'FFFFull>() { + return 9223372036854774784.0; // 0x7FFFFFFFFFFFFC00p0 + } + template <> + constexpr double MaxCeilValue<0x7FFF'FFFF'FFFF'FFFFull>() { + return 9223372036854775808.0; // 0x8000000000000000p0 + } + template <> + constexpr double MaxFloorValue<0xFFFF'FFFF'FFFF'FFFFull>() { + return 18446744073709549568.0; // 0xFFFFFFFFFFFFF800p0 + } + template <> + constexpr double MaxCeilValue<0xFFFF'FFFF'FFFF'FFFFull>() { + return 18446744073709551616.0; // 0x10000000000000000p0 + } +} + +// MaxFloor<T> is the greatest double within the range of T. +// +// 1. If Max<T> is an exact double, MaxFloor<T> = Max<T> = MaxCeil<T>. +// In this case some doubles above MaxFloor<T> cast to T may round +// to Max<T> depending on the rounding mode. +// +// 2. Otherwise Max<T> is between MaxFloor<T> and MaxCeil<T>, and +// MaxFloor<T> is the largest double that does not overflow T. +template <class T> +static constexpr double MaxFloor() noexcept { + return ::NPrivate::MaxFloorValue<Max<T>()>(); +} + +// MaxCeil<T> is the smallest double not lesser than Max<T>. +// +// 1. If Max<T> is an exact double, MaxCeil<T> = Max<T> = MaxFloor<T>. +// +// 2. Otherwise Max<T> is between MaxFloor<T> and MaxCeil<T>, and +// MaxCeil<T> is the smallest double that overflows T. +template <class T> +static constexpr double MaxCeil() noexcept { + return ::NPrivate::MaxCeilValue<Max<T>()>(); +} diff --git a/util/generic/ylimits_ut.cpp b/util/generic/ylimits_ut.cpp index 029905ed55..f1b3c6858c 100644 --- a/util/generic/ylimits_ut.cpp +++ b/util/generic/ylimits_ut.cpp @@ -10,13 +10,13 @@ class TLimitTest: public TTestBase { UNIT_TEST_SUITE(TLimitTest); UNIT_TEST(TestLimits); UNIT_TEST(TestNan); - UNIT_TEST(TestMaxDouble); + UNIT_TEST(TestMaxDouble); UNIT_TEST_SUITE_END(); protected: void TestLimits(); void TestNan(); - void TestMaxDouble(); + void TestMaxDouble(); }; UNIT_TEST_SUITE_REGISTRATION(TLimitTest); @@ -142,16 +142,16 @@ void TLimitTest::TestNan() { using long_double = long double; UNIT_ASSERT(::TestNan(long_double())); } - -void TLimitTest::TestMaxDouble() { - UNIT_ASSERT_VALUES_EQUAL(MaxCeil<i8>(), 127.0); - UNIT_ASSERT_VALUES_EQUAL(MaxFloor<i8>(), 127.0); - UNIT_ASSERT_VALUES_EQUAL(MaxCeil<ui8>(), 255.0); - UNIT_ASSERT_VALUES_EQUAL(MaxFloor<ui8>(), 255.0); - double d = 1ull << 63; - UNIT_ASSERT_VALUES_EQUAL(MaxCeil<i64>(), d); - UNIT_ASSERT_VALUES_EQUAL(MaxFloor<i64>(), nextafter(d, 0)); - d *= 2; - UNIT_ASSERT_VALUES_EQUAL(MaxCeil<ui64>(), d); - UNIT_ASSERT_VALUES_EQUAL(MaxFloor<ui64>(), nextafter(d, 0)); -} + +void TLimitTest::TestMaxDouble() { + UNIT_ASSERT_VALUES_EQUAL(MaxCeil<i8>(), 127.0); + UNIT_ASSERT_VALUES_EQUAL(MaxFloor<i8>(), 127.0); + UNIT_ASSERT_VALUES_EQUAL(MaxCeil<ui8>(), 255.0); + UNIT_ASSERT_VALUES_EQUAL(MaxFloor<ui8>(), 255.0); + double d = 1ull << 63; + UNIT_ASSERT_VALUES_EQUAL(MaxCeil<i64>(), d); + UNIT_ASSERT_VALUES_EQUAL(MaxFloor<i64>(), nextafter(d, 0)); + d *= 2; + UNIT_ASSERT_VALUES_EQUAL(MaxCeil<ui64>(), d); + UNIT_ASSERT_VALUES_EQUAL(MaxFloor<ui64>(), nextafter(d, 0)); +} diff --git a/util/memory/pool.h b/util/memory/pool.h index bc492f2ffd..13c8b6b9ed 100644 --- a/util/memory/pool.h +++ b/util/memory/pool.h @@ -9,9 +9,9 @@ #include <util/generic/intrlist.h> #include <util/generic/strbuf.h> #include <util/generic/singleton.h> - + #include <new> -#include <string> +#include <string> #include <utility> /** @@ -207,14 +207,14 @@ public: template <typename TChar> inline TChar* Append(const TChar* str) { - return Append(str, std::char_traits<TChar>::length(str) + 1); // include terminating zero byte + return Append(str, std::char_traits<TChar>::length(str) + 1); // include terminating zero byte } template <typename TChar> inline TChar* Append(const TChar* str, size_t len) { TChar* ret = AllocateArray<TChar>(len); - std::char_traits<TChar>::copy(ret, str, len); + std::char_traits<TChar>::copy(ret, str, len); return ret; } @@ -227,7 +227,7 @@ public: inline TBasicStringBuf<TChar> AppendCString(const TBasicStringBuf<TChar>& buf) { TChar* ret = static_cast<TChar*>(Allocate((buf.size() + 1) * sizeof(TChar))); - std::char_traits<TChar>::copy(ret, buf.data(), buf.size()); + std::char_traits<TChar>::copy(ret, buf.data(), buf.size()); *(ret + buf.size()) = 0; return TBasicStringBuf<TChar>(ret, buf.size()); } diff --git a/util/stream/direct_io.cpp b/util/stream/direct_io.cpp index 9f7de8e613..649033af34 100644 --- a/util/stream/direct_io.cpp +++ b/util/stream/direct_io.cpp @@ -21,21 +21,21 @@ size_t TRandomAccessFileInput::DoSkip(size_t len) { } TRandomAccessFileOutput::TRandomAccessFileOutput(TDirectIOBufferedFile& file) - : File(&file) + : File(&file) { } void TRandomAccessFileOutput::DoWrite(const void* buf, size_t len) { - File->Write(buf, len); + File->Write(buf, len); } void TRandomAccessFileOutput::DoFlush() { - File->FlushData(); + File->FlushData(); } TBufferedFileOutputEx::TBufferedFileOutputEx(const TString& path, EOpenMode oMode, size_t buflen) : TRandomAccessFileOutput(*(new TDirectIOBufferedFile(path, oMode, buflen))) - , FileHolder(File) + , FileHolder(File) { } diff --git a/util/stream/direct_io.h b/util/stream/direct_io.h index fed8e88c3a..2e1f2e07dd 100644 --- a/util/stream/direct_io.h +++ b/util/stream/direct_io.h @@ -25,7 +25,7 @@ public: TRandomAccessFileOutput& operator=(TRandomAccessFileOutput&&) noexcept = default; protected: - TDirectIOBufferedFile* File; + TDirectIOBufferedFile* File; private: void DoWrite(const void* buf, size_t len) override; diff --git a/util/stream/output.cpp b/util/stream/output.cpp index 3abb22bed4..db81b81b70 100644 --- a/util/stream/output.cpp +++ b/util/stream/output.cpp @@ -132,7 +132,7 @@ void Out<TUtf32StringBuf>(IOutputStream& o, const TUtf32StringBuf& p) { template <> void Out<const wchar16*>(IOutputStream& o, const wchar16* w) { if (w) { - WriteString(o, w, std::char_traits<wchar16>::length(w)); + WriteString(o, w, std::char_traits<wchar16>::length(w)); } else { o.Write("(null)"); } @@ -141,7 +141,7 @@ void Out<const wchar16*>(IOutputStream& o, const wchar16* w) { template <> void Out<const wchar32*>(IOutputStream& o, const wchar32* w) { if (w) { - WriteString(o, w, std::char_traits<wchar32>::length(w)); + WriteString(o, w, std::char_traits<wchar32>::length(w)); } else { o.Write("(null)"); } @@ -174,11 +174,11 @@ void Out<TUtf32String>(IOutputStream& o, const TUtf32String& w) { void Out<type>(IOutputStream & o, type p) { \ char buf[len]; \ o.Write(buf, ToString(p, buf, sizeof(buf))); \ - } \ - \ - template <> \ - void Out<volatile type>(IOutputStream & o, volatile type p) { \ - Out<type>(o, p); \ + } \ + \ + template <> \ + void Out<volatile type>(IOutputStream & o, volatile type p) { \ + Out<type>(o, p); \ } DEF_CONV_NUM(bool, 64) diff --git a/util/stream/str.cpp b/util/stream/str.cpp index 9622a1a254..13f0e8ef28 100644 --- a/util/stream/str.cpp +++ b/util/stream/str.cpp @@ -5,8 +5,8 @@ static constexpr size_t MIN_BUFFER_GROW_SIZE = 16; TStringInput::~TStringInput() = default; size_t TStringInput::DoNext(const void** ptr, size_t len) { - len = Min(len, S_->size() - Pos_); - *ptr = S_->data() + Pos_; + len = Min(len, S_->size() - Pos_); + *ptr = S_->data() + Pos_; Pos_ += len; return len; } diff --git a/util/stream/str.h b/util/stream/str.h index 6233e73671..028bd572c0 100644 --- a/util/stream/str.h +++ b/util/stream/str.h @@ -30,7 +30,7 @@ public: * @param s String to read from. */ inline TStringInput(const TString& s) noexcept - : S_(&s) + : S_(&s) , Pos_(0) { } @@ -52,7 +52,7 @@ protected: void DoUndo(size_t len) override; private: - const TString* S_; + const TString* S_; size_t Pos_; friend class TStringStream; diff --git a/util/string/cast.h b/util/string/cast.h index d890b5a068..90e925c194 100644 --- a/util/string/cast.h +++ b/util/string/cast.h @@ -147,7 +147,7 @@ inline T FromString(const TChar* data, size_t len) { template <typename T, typename TChar> inline T FromString(const TChar* data) { - return ::FromString<T>(data, std::char_traits<TChar>::length(data)); + return ::FromString<T>(data, std::char_traits<TChar>::length(data)); } template <class T> @@ -207,7 +207,7 @@ inline ::NPrivate::TFromString<TChar> FromString(const TChar* data, size_t len) template <typename TChar> inline ::NPrivate::TFromString<TChar> FromString(const TChar* data) { - return ::NPrivate::TFromString<TChar>(data, std::char_traits<TChar>::length(data)); + return ::NPrivate::TFromString<TChar>(data, std::char_traits<TChar>::length(data)); } template <typename T> @@ -233,7 +233,7 @@ inline bool TryFromString(const TChar* data, size_t len, T& result) { template <typename T, typename TChar> inline bool TryFromString(const TChar* data, T& result) { - return TryFromString<T>(data, std::char_traits<TChar>::length(data), result); + return TryFromString<T>(data, std::char_traits<TChar>::length(data), result); } template <class T, class TChar> @@ -336,7 +336,7 @@ TInt IntFromString(const TChar* str, size_t len); template <class TInt, int base, class TChar> inline TInt IntFromString(const TChar* str) { - return IntFromString<TInt, base>(str, std::char_traits<TChar>::length(str)); + return IntFromString<TInt, base>(str, std::char_traits<TChar>::length(str)); } template <class TInt, int base, class TStringType> diff --git a/util/string/escape.h b/util/string/escape.h index 2f56882d26..b01be65b0e 100644 --- a/util/string/escape.h +++ b/util/string/escape.h @@ -46,7 +46,7 @@ static inline TBasicString<TChar> EscapeC(TChar ch) { template <typename TChar> static inline TBasicString<TChar> EscapeC(const TChar* str) { - return EscapeC(str, std::char_traits<TChar>::length(str)); + return EscapeC(str, std::char_traits<TChar>::length(str)); } TString& EscapeC(const TStringBuf str, TString& res); diff --git a/util/string/join.h b/util/string/join.h index 5c7bb70791..b166fad1f3 100644 --- a/util/string/join.h +++ b/util/string/join.h @@ -62,7 +62,7 @@ namespace NPrivate { template <> inline size_t GetLength(const char* const& s) { - return (s ? std::char_traits<char>::length(s) : 0); + return (s ? std::char_traits<char>::length(s) : 0); } inline size_t GetAppendLength(const TStringBuf /*delim*/) { diff --git a/util/string/split.h b/util/string/split.h index 38b0d765a0..bc46d9e64c 100644 --- a/util/string/split.h +++ b/util/string/split.h @@ -76,7 +76,7 @@ static inline I1* FastStrChr(I1* str, I2 f) noexcept { I1* ret = NStringSplitPrivate::Find(str, f); if (!ret) { - ret = str + std::char_traits<I1>::length(str); + ret = str + std::char_traits<I1>::length(str); } return ret; @@ -106,7 +106,7 @@ template <class Char> struct TStringDelimiter { inline TStringDelimiter(Char* delim) noexcept : Delim(delim) - , Len(std::char_traits<Char>::length(delim)) + , Len(std::char_traits<Char>::length(delim)) { } diff --git a/util/string/vector.cpp b/util/string/vector.cpp index ae263ada8d..9ba401f0a2 100644 --- a/util/string/vector.cpp +++ b/util/string/vector.cpp @@ -53,7 +53,7 @@ static void SplitStringImplT(TVector<std::conditional_t<std::is_same<TChr, wchar } if (*(delim + 1)) { - TStringDelimiter<const TChr> d(delim, std::char_traits<TChr>::length(delim)); + TStringDelimiter<const TChr> d(delim, std::char_traits<TChr>::length(delim)); DoSplit0(res, str, d, maxFields, options); } else { diff --git a/util/system/file.cpp b/util/system/file.cpp index 54bf27525f..4a261d020c 100644 --- a/util/system/file.cpp +++ b/util/system/file.cpp @@ -512,7 +512,7 @@ i32 TFileHandle::Pread(void* buffer, ui32 byteCount, i64 offset) const noexcept return bytesRead; } if (::GetLastError() == ERROR_HANDLE_EOF) { - return 0; + return 0; } return -1; #elif defined(_unix_) diff --git a/util/system/mlock.cpp b/util/system/mlock.cpp index c70f8f3351..435338c98f 100644 --- a/util/system/mlock.cpp +++ b/util/system/mlock.cpp @@ -66,9 +66,9 @@ void LockAllMemory(ELockAllMemoryFlags flags) { if (flags & LockFutureMemory) { sys_flags |= MCL_FUTURE; } - if (flags & LockMemoryOnFault) { - sys_flags |= MCL_ONFAULT; - } + if (flags & LockMemoryOnFault) { + sys_flags |= MCL_ONFAULT; + } if (mlockall(sys_flags)) { ythrow yexception() << LastSystemErrorText(); } diff --git a/util/system/mlock.h b/util/system/mlock.h index 69c933776e..f021c0fe67 100644 --- a/util/system/mlock.h +++ b/util/system/mlock.h @@ -19,9 +19,9 @@ enum ELockAllMemoryFlag { /** Lock all pages which will become mapped into the address space of the process in the future. */ LockFutureMemory = 2, - - /** Since Linux 4.4, with LockCurrentMemory or LockFutureMemory or both, lock only pages that are or once they are present in memory. */ - LockMemoryOnFault = 4, + + /** Since Linux 4.4, with LockCurrentMemory or LockFutureMemory or both, lock only pages that are or once they are present in memory. */ + LockMemoryOnFault = 4, }; Y_DECLARE_FLAGS(ELockAllMemoryFlags, ELockAllMemoryFlag) Y_DECLARE_OPERATORS_FOR_FLAGS(ELockAllMemoryFlags) diff --git a/util/system/user.cpp b/util/system/user.cpp index e730f621cd..83e89ea0a8 100644 --- a/util/system/user.cpp +++ b/util/system/user.cpp @@ -1,7 +1,7 @@ #include "user.h" #include "platform.h" #include "defaults.h" -#include "env.h" +#include "env.h" #include <util/generic/yexception.h> @@ -14,13 +14,13 @@ #endif TString GetUsername() { - for (const auto& var : {"LOGNAME", "USER", "LNAME", "USERNAME"}) { - TString val = GetEnv(var); + for (const auto& var : {"LOGNAME", "USER", "LNAME", "USERNAME"}) { + TString val = GetEnv(var); if (val) { - return val; + return val; } - } - + } + TTempBuf nameBuf; for (;;) { #if defined(_win_) diff --git a/util/thread/lfstack.h b/util/thread/lfstack.h index b94bf11b48..ca3d95f3c3 100644 --- a/util/thread/lfstack.h +++ b/util/thread/lfstack.h @@ -35,14 +35,14 @@ class TLockFreeStack: TNonCopyable { EraseList(current); } } - void EraseList(TNode* volatile p) { + void EraseList(TNode* volatile p) { while (p) { TNode* next = p->Next; delete p; p = next; } } - void EnqueueImpl(TNode* volatile head, TNode* volatile tail) { + void EnqueueImpl(TNode* volatile head, TNode* volatile tail) { for (;;) { tail->Next = AtomicGet(Head); if (AtomicCas(&Head, head, tail->Next)) @@ -51,7 +51,7 @@ class TLockFreeStack: TNonCopyable { } template <class U> void EnqueueImpl(U&& u) { - TNode* volatile node = new TNode(std::forward<U>(u)); + TNode* volatile node = new TNode(std::forward<U>(u)); EnqueueImpl(node, node); } @@ -85,8 +85,8 @@ public: return; } TIter i = dataBegin; - TNode* volatile node = new TNode(*i); - TNode* volatile tail = node; + TNode* volatile node = new TNode(*i); + TNode* volatile tail = node; for (++i; i != dataEnd; ++i) { TNode* nextNode = node; |