diff options
author | mihaild <mihaild@yandex-team.ru> | 2022-02-10 16:46:59 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:59 +0300 |
commit | 246417ad6168d3f7ab4a0cf1c79ba4259f7c45ae (patch) | |
tree | 2a65611ade91c8ae2f55647107c1a11ea743abd5 /util | |
parent | 5598c5e7bc7619bd51d87fea7b880b7788ad0b47 (diff) | |
download | ydb-246417ad6168d3f7ab4a0cf1c79ba4259f7c45ae.tar.gz |
Restoring authorship annotation for <mihaild@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
29 files changed, 312 insertions, 312 deletions
diff --git a/util/charset/benchmark/utf8_to_wide/main.cpp b/util/charset/benchmark/utf8_to_wide/main.cpp index 09fa567fe5..7683b4dd15 100644 --- a/util/charset/benchmark/utf8_to_wide/main.cpp +++ b/util/charset/benchmark/utf8_to_wide/main.cpp @@ -19,33 +19,33 @@ namespace { } }; - template <size_t N> + template <size_t N> struct TRandomRuString: public TVector<char> { - inline TRandomRuString() { + inline TRandomRuString() { TVector<unsigned char> data(N * 2); - unsigned char* textEnd = data.begin(); - for (size_t i = 0; i < N; ++i) { - size_t runeLen; + unsigned char* textEnd = data.begin(); + for (size_t i = 0; i < N; ++i) { + size_t runeLen; WriteUTF8Char(RandomNumber<ui32>(0x7FF) + 1, runeLen, textEnd); - textEnd += runeLen; - } - assign(reinterpret_cast<const char*>(data.begin()), reinterpret_cast<const char*>(textEnd)); - } - }; - + textEnd += runeLen; + } + assign(reinterpret_cast<const char*>(data.begin()), reinterpret_cast<const char*>(textEnd)); + } + }; + using RAS1 = TRandomAsciiString<1>; using RAS10 = TRandomAsciiString<10>; using RAS50 = TRandomAsciiString<50>; using RAS1000 = TRandomAsciiString<1000>; using RAS1000000 = TRandomAsciiString<1000000>; - - using RRS1 = TRandomRuString<1>; - using RRS10 = TRandomRuString<10>; - using RRS1000 = TRandomRuString<1000>; - using RRS1000000 = TRandomRuString<1000000>; + + using RRS1 = TRandomRuString<1>; + using RRS10 = TRandomRuString<10>; + using RRS1000 = TRandomRuString<1000>; + using RRS1000000 = TRandomRuString<1000000>; } -#ifdef _sse2_ +#ifdef _sse2_ #define IS_ASCII_BENCHMARK(length) \ Y_CPU_BENCHMARK(IsStringASCII##length, iface) { \ const auto& data = *Singleton<RAS##length>(); \ @@ -65,7 +65,7 @@ namespace { Y_DO_NOT_OPTIMIZE_AWAY(::NDetail::DoIsStringASCIISSE(reinterpret_cast<const unsigned char*>(data.begin()), reinterpret_cast<const unsigned char*>(data.end()))); \ } \ } -#else //no sse +#else //no sse #define IS_ASCII_BENCHMARK(length) \ Y_CPU_BENCHMARK(IsStringASCIIScalar##length, iface) { \ const auto& data = *Singleton<RAS##length>(); \ @@ -79,33 +79,33 @@ namespace { Y_DO_NOT_OPTIMIZE_AWAY(::NDetail::DoIsStringASCIISlow(data.begin(), data.end())); \ } \ } -#endif - -IS_ASCII_BENCHMARK(1); -IS_ASCII_BENCHMARK(10); -IS_ASCII_BENCHMARK(50); -IS_ASCII_BENCHMARK(1000); -IS_ASCII_BENCHMARK(1000000); - -template <bool robust, typename TCharType> -inline size_t UTF8ToWideImplScalar(const char* text, size_t len, TCharType* dest, size_t& written) { - const unsigned char* cur = reinterpret_cast<const unsigned char*>(text); - const unsigned char* last = cur + len; - TCharType* p = dest; - - ::NDetail::UTF8ToWideImplScalar<robust>(cur, last, p); - written = p - dest; - return cur - reinterpret_cast<const unsigned char*>(text); -} - -template <bool robust, typename TCharType> -inline size_t UTF8ToWideImplSSE(const char* text, size_t len, TCharType* dest, size_t& written) { - return UTF8ToWideImpl(text, len, dest, written); -} - +#endif + +IS_ASCII_BENCHMARK(1); +IS_ASCII_BENCHMARK(10); +IS_ASCII_BENCHMARK(50); +IS_ASCII_BENCHMARK(1000); +IS_ASCII_BENCHMARK(1000000); + +template <bool robust, typename TCharType> +inline size_t UTF8ToWideImplScalar(const char* text, size_t len, TCharType* dest, size_t& written) { + const unsigned char* cur = reinterpret_cast<const unsigned char*>(text); + const unsigned char* last = cur + len; + TCharType* p = dest; + + ::NDetail::UTF8ToWideImplScalar<robust>(cur, last, p); + written = p - dest; + return cur - reinterpret_cast<const unsigned char*>(text); +} + +template <bool robust, typename TCharType> +inline size_t UTF8ToWideImplSSE(const char* text, size_t len, TCharType* dest, size_t& written) { + return UTF8ToWideImpl(text, len, dest, written); +} + static wchar16 WBUF_UTF16[10000000]; static wchar32 WBUF_UTF32[10000000]; - + #define UTF8_TO_WIDE_SCALAR_BENCHMARK_ASCII(impl, length, to) \ Y_CPU_BENCHMARK(UTF8ToWideASCII##impl##length##to, iface) { \ const auto& data = *Singleton<RAS##length>(); \ @@ -113,8 +113,8 @@ static wchar32 WBUF_UTF32[10000000]; size_t written = 0; \ Y_DO_NOT_OPTIMIZE_AWAY(UTF8ToWideImpl##impl<false>(data.begin(), data.size(), WBUF_##to, written)); \ } \ - } - + } + #define UTF8_TO_WIDE_SCALAR_BENCHMARK_RU(impl, length, to) \ Y_CPU_BENCHMARK(UTF8ToWideRU##impl##length##to, iface) { \ const auto& data = *Singleton<RRS##length>(); \ @@ -122,8 +122,8 @@ static wchar32 WBUF_UTF32[10000000]; size_t written = 0; \ Y_DO_NOT_OPTIMIZE_AWAY(UTF8ToWideImpl##impl<false>(data.begin(), data.size(), WBUF_##to, written)); \ } \ - } - + } + UTF8_TO_WIDE_SCALAR_BENCHMARK_ASCII(Scalar, 1, UTF16); UTF8_TO_WIDE_SCALAR_BENCHMARK_ASCII(SSE, 1, UTF16); UTF8_TO_WIDE_SCALAR_BENCHMARK_ASCII(Scalar, 10, UTF16); @@ -132,7 +132,7 @@ UTF8_TO_WIDE_SCALAR_BENCHMARK_ASCII(Scalar, 1000, UTF16); UTF8_TO_WIDE_SCALAR_BENCHMARK_ASCII(SSE, 1000, UTF16); UTF8_TO_WIDE_SCALAR_BENCHMARK_ASCII(Scalar, 1000000, UTF16); UTF8_TO_WIDE_SCALAR_BENCHMARK_ASCII(SSE, 1000000, UTF16); - + UTF8_TO_WIDE_SCALAR_BENCHMARK_RU(Scalar, 1, UTF16); UTF8_TO_WIDE_SCALAR_BENCHMARK_RU(SSE, 1, UTF16); UTF8_TO_WIDE_SCALAR_BENCHMARK_RU(Scalar, 10, UTF16); diff --git a/util/charset/generated/unidata.cpp b/util/charset/generated/unidata.cpp index 6f5adbbc0a..27579cab8a 100644 --- a/util/charset/generated/unidata.cpp +++ b/util/charset/generated/unidata.cpp @@ -7530,9 +7530,9 @@ namespace NUnicode { } } // namespace NPrivate } // namespace NUnicode -namespace NUnicode { - namespace NPrivate { - const size_t DEFAULT_KEY = 0xE001; - static_assert(NUnidataTableGenerated::Size > DEFAULT_KEY, "table size should be greater then default key"); - } -} +namespace NUnicode { + namespace NPrivate { + const size_t DEFAULT_KEY = 0xE001; + static_assert(NUnidataTableGenerated::Size > DEFAULT_KEY, "table size should be greater then default key"); + } +} diff --git a/util/charset/unicode_table.h b/util/charset/unicode_table.h index 9e171b2583..80f88a0ba5 100644 --- a/util/charset/unicode_table.h +++ b/util/charset/unicode_table.h @@ -88,10 +88,10 @@ namespace NUnicodeTable { return TImpl::Get(val); } - inline TValueRef Get(size_t key) const { - return GetImpl(key); - } - + inline TValueRef Get(size_t key) const { + return GetImpl(key); + } + public: TTable(TData data, size_t size) : Data(data) diff --git a/util/charset/unidata.h b/util/charset/unidata.h index 400d314186..a407d1a227 100644 --- a/util/charset/unidata.h +++ b/util/charset/unidata.h @@ -110,13 +110,13 @@ namespace NUnicode { TCombining Combining; }; - extern const size_t DEFAULT_KEY; - + extern const size_t DEFAULT_KEY; + using TUnidataTable = NUnicodeTable::TTable<NUnicodeTable::TSubtable<NUnicodeTable::UNICODE_TABLE_SHIFT, NUnicodeTable::TValues<TProperty>>>; const TUnidataTable& UnidataTable(); inline const TProperty& CharProperty(wchar32 ch) { - return UnidataTable().Get(ch, DEFAULT_KEY); + return UnidataTable().Get(ch, DEFAULT_KEY); } inline ui32 CharInfo(wchar32 ch) { diff --git a/util/charset/utf8.h b/util/charset/utf8.h index 5039b46ae9..9b4c9a05b0 100644 --- a/util/charset/utf8.h +++ b/util/charset/utf8.h @@ -16,24 +16,24 @@ inline unsigned char UTF8LeadByteMask(size_t utf8_rune_len) { } inline size_t UTF8RuneLen(const unsigned char lead_byte) { - //b0XXXXXXX - if ((lead_byte & 0x80) == 0x00) { - return 1; - } - //b110XXXXX - if ((lead_byte & 0xe0) == 0xc0) { - return 2; - } - //b1110XXXX - if ((lead_byte & 0xf0) == 0xe0) { - return 3; - } - //b11110XXX - if ((lead_byte & 0xf8) == 0xf0) { - return 4; - } - //b10XXXXXX - return 0; + //b0XXXXXXX + if ((lead_byte & 0x80) == 0x00) { + return 1; + } + //b110XXXXX + if ((lead_byte & 0xe0) == 0xc0) { + return 2; + } + //b1110XXXX + if ((lead_byte & 0xf0) == 0xe0) { + return 3; + } + //b11110XXX + if ((lead_byte & 0xf8) == 0xf0) { + return 4; + } + //b10XXXXXX + return 0; } inline size_t UTF8RuneLenByUCS(wchar32 rune) { diff --git a/util/charset/utf8_ut.cpp b/util/charset/utf8_ut.cpp index 9e68881cca..8eadb3f808 100644 --- a/util/charset/utf8_ut.cpp +++ b/util/charset/utf8_ut.cpp @@ -108,19 +108,19 @@ Y_UNIT_TEST_SUITE(TUtfUtilTest) { UNIT_ASSERT_EXCEPTION(UTF8ToWide(text), yexception); } } - + Y_UNIT_TEST(TestUTF8ToWideScalar) { TFileInput in(ArcadiaSourceRoot() + TStringBuf("/util/charset/ut/utf8/test1.txt")); - + TString text = in.ReadAll(); TUtf16String wtextSSE = UTF8ToWide(text); TUtf16String wtextScalar = TUtf16String::Uninitialized(text.size()); - const unsigned char* textBegin = reinterpret_cast<const unsigned char*>(text.c_str()); - wchar16* wtextBegin = wtextScalar.begin(); - ::NDetail::UTF8ToWideImplScalar<false>(textBegin, textBegin + text.size(), wtextBegin); - UNIT_ASSERT(wtextBegin == wtextScalar.begin() + wtextSSE.size()); - UNIT_ASSERT(textBegin == reinterpret_cast<const unsigned char*>(text.end())); - wtextScalar.remove(wtextSSE.size()); - UNIT_ASSERT(wtextScalar == wtextSSE); - } + const unsigned char* textBegin = reinterpret_cast<const unsigned char*>(text.c_str()); + wchar16* wtextBegin = wtextScalar.begin(); + ::NDetail::UTF8ToWideImplScalar<false>(textBegin, textBegin + text.size(), wtextBegin); + UNIT_ASSERT(wtextBegin == wtextScalar.begin() + wtextSSE.size()); + UNIT_ASSERT(textBegin == reinterpret_cast<const unsigned char*>(text.end())); + wtextScalar.remove(wtextSSE.size()); + UNIT_ASSERT(wtextScalar == wtextSSE); + } } diff --git a/util/charset/wide.h b/util/charset/wide.h index 04e6928aab..8e41529842 100644 --- a/util/charset/wide.h +++ b/util/charset/wide.h @@ -13,12 +13,12 @@ #include <util/system/cpu_id.h> #include <util/system/yassert.h> -#include <cstring> - -#ifdef _sse2_ +#include <cstring> + +#ifdef _sse2_ #include <emmintrin.h> -#endif - +#endif + template <class T> class TTempArray; using TCharTemp = TTempArray<wchar16>; @@ -258,26 +258,26 @@ public: } }; -namespace NDetail { - template <bool robust, typename TCharType> +namespace NDetail { + template <bool robust, typename TCharType> inline void UTF8ToWideImplScalar(const unsigned char*& cur, const unsigned char* last, TCharType*& dest) noexcept { - wchar32 rune = BROKEN_RUNE; - - while (cur != last) { - if (ReadUTF8CharAndAdvance(rune, cur, last) != RECODE_OK) { - if (robust) { - rune = BROKEN_RUNE; - ++cur; - } else { - break; - } - } - - Y_ASSERT(cur <= last); - WriteSymbol(rune, dest); - } - } - + wchar32 rune = BROKEN_RUNE; + + while (cur != last) { + if (ReadUTF8CharAndAdvance(rune, cur, last) != RECODE_OK) { + if (robust) { + rune = BROKEN_RUNE; + ++cur; + } else { + break; + } + } + + Y_ASSERT(cur <= last); + WriteSymbol(rune, dest); + } + } + template <typename TCharType> inline void UTF16ToUTF32ImplScalar(const wchar16* cur, const wchar16* last, TCharType*& dest) noexcept { wchar32 rune = BROKEN_RUNE; @@ -289,28 +289,28 @@ namespace NDetail { } } - template <class TCharType> - inline void UTF8ToWideImplSSE41(const unsigned char*& /*cur*/, const unsigned char* /*last*/, TCharType*& /*dest*/) noexcept { - } - - void UTF8ToWideImplSSE41(const unsigned char*& cur, const unsigned char* last, wchar16*& dest) noexcept; + template <class TCharType> + inline void UTF8ToWideImplSSE41(const unsigned char*& /*cur*/, const unsigned char* /*last*/, TCharType*& /*dest*/) noexcept { + } + + void UTF8ToWideImplSSE41(const unsigned char*& cur, const unsigned char* last, wchar16*& dest) noexcept; void UTF8ToWideImplSSE41(const unsigned char*& cur, const unsigned char* last, wchar32*& dest) noexcept; } - + //! @return len if robust and position where encoding stopped if not template <bool robust, typename TCharType> inline size_t UTF8ToWideImpl(const char* text, size_t len, TCharType* dest, size_t& written) noexcept { const unsigned char* cur = reinterpret_cast<const unsigned char*>(text); - const unsigned char* last = cur + len; + const unsigned char* last = cur + len; TCharType* p = dest; -#ifdef _sse_ //can't check for sse4, as we build most of arcadia without sse4 support even on platforms that support it - if (cur + 16 <= last && NX86::CachedHaveSSE41()) { - ::NDetail::UTF8ToWideImplSSE41(cur, last, p); - } -#endif +#ifdef _sse_ //can't check for sse4, as we build most of arcadia without sse4 support even on platforms that support it + if (cur + 16 <= last && NX86::CachedHaveSSE41()) { + ::NDetail::UTF8ToWideImplSSE41(cur, last, p); + } +#endif - ::NDetail::UTF8ToWideImplScalar<robust>(cur, last, p); + ::NDetail::UTF8ToWideImplScalar<robust>(cur, last, p); written = p - dest; return cur - reinterpret_cast<const unsigned char*>(text); } @@ -510,22 +510,22 @@ namespace NDetail { }; template <typename TChar> - inline bool DoIsStringASCIISlow(const TChar* first, const TChar* last) { + inline bool DoIsStringASCIISlow(const TChar* first, const TChar* last) { using TUnsignedChar = std::make_unsigned_t<TChar>; - Y_ASSERT(first <= last); - for (; first != last; ++first) { - if (static_cast<TUnsignedChar>(*first) > 0x7F) { - return false; - } - } - return true; - } - - template <typename TChar> + Y_ASSERT(first <= last); + for (; first != last; ++first) { + if (static_cast<TUnsignedChar>(*first) > 0x7F) { + return false; + } + } + return true; + } + + template <typename TChar> inline bool DoIsStringASCII(const TChar* first, const TChar* last) { - if (last - first < 10) { - return DoIsStringASCIISlow(first, last); - } + if (last - first < 10) { + return DoIsStringASCIISlow(first, last); + } TMachineWord allCharBits = 0; TMachineWord nonAsciiBitMask = NonASCIIMask<sizeof(TMachineWord), TChar>::Value(); @@ -557,40 +557,40 @@ namespace NDetail { return !(allCharBits & nonAsciiBitMask); } -#ifdef _sse2_ - inline bool DoIsStringASCIISSE(const unsigned char* first, const unsigned char* last) { - //scalar version for short strings - if (first + 8 > last) { - return ::NDetail::DoIsStringASCIISlow(first, last); - } - - alignas(16) unsigned char buf[16]; - - while (first + 16 <= last) { - memcpy(buf, first, 16); - __m128i chunk = _mm_load_si128(reinterpret_cast<__m128i*>(buf)); - - int asciiMask = _mm_movemask_epi8(chunk); - if (asciiMask) { +#ifdef _sse2_ + inline bool DoIsStringASCIISSE(const unsigned char* first, const unsigned char* last) { + //scalar version for short strings + if (first + 8 > last) { + return ::NDetail::DoIsStringASCIISlow(first, last); + } + + alignas(16) unsigned char buf[16]; + + while (first + 16 <= last) { + memcpy(buf, first, 16); + __m128i chunk = _mm_load_si128(reinterpret_cast<__m128i*>(buf)); + + int asciiMask = _mm_movemask_epi8(chunk); + if (asciiMask) { return false; } - first += 16; + first += 16; } - - if (first + 8 <= last) { - memcpy(buf, first, 8); - __m128i chunk = _mm_loadl_epi64(reinterpret_cast<__m128i*>(buf)); - - int asciiMask = _mm_movemask_epi8(chunk); - if (asciiMask) { - return false; - } - first += 8; - } - - return ::NDetail::DoIsStringASCIISlow(first, last); + + if (first + 8 <= last) { + memcpy(buf, first, 8); + __m128i chunk = _mm_loadl_epi64(reinterpret_cast<__m128i*>(buf)); + + int asciiMask = _mm_movemask_epi8(chunk); + if (asciiMask) { + return false; + } + first += 8; + } + + return ::NDetail::DoIsStringASCIISlow(first, last); } -#endif //_sse2_ +#endif //_sse2_ } @@ -600,17 +600,17 @@ inline bool IsStringASCII(const TChar* first, const TChar* last) { return ::NDetail::DoIsStringASCII(first, last); } -#ifdef _sse2_ -template <> -inline bool IsStringASCII<unsigned char>(const unsigned char* first, const unsigned char* last) { - return ::NDetail::DoIsStringASCIISSE(first, last); -} -template <> -inline bool IsStringASCII<char>(const char* first, const char* last) { - return ::NDetail::DoIsStringASCIISSE(reinterpret_cast<const unsigned char*>(first), reinterpret_cast<const unsigned char*>(last)); -} -#endif - +#ifdef _sse2_ +template <> +inline bool IsStringASCII<unsigned char>(const unsigned char* first, const unsigned char* last) { + return ::NDetail::DoIsStringASCIISSE(first, last); +} +template <> +inline bool IsStringASCII<char>(const char* first, const char* last) { + return ::NDetail::DoIsStringASCIISSE(reinterpret_cast<const unsigned char*>(first), reinterpret_cast<const unsigned char*>(last)); +} +#endif + //! copies elements from one character sequence to another using memcpy //! for compatibility only template <typename TChar> diff --git a/util/charset/wide_sse41.cpp b/util/charset/wide_sse41.cpp index d1f2a74851..6859e9c44c 100644 --- a/util/charset/wide_sse41.cpp +++ b/util/charset/wide_sse41.cpp @@ -1,6 +1,6 @@ -#include <util/charset/wide.h> +#include <util/charset/wide.h> #include <util/system/types.h> - + #ifdef SSE41_STUB namespace NDetail { @@ -13,21 +13,21 @@ namespace NDetail { #else #include <util/system/compiler.h> - + #include <cstring> #include <emmintrin.h> #include <smmintrin.h> - -//processes to the first error, or until less then 16 bytes left -//most code taken from https://woboq.com/blog/utf-8-processing-using-simd.html - + +//processes to the first error, or until less then 16 bytes left +//most code taken from https://woboq.com/blog/utf-8-processing-using-simd.html + //return dstAdvance 0 in case of problems static Y_FORCE_INLINE ui32 Unpack16BytesIntoUtf16IfNoSurrogats(const unsigned char*& cur, __m128i& utf16Low, __m128i& utf16High) { unsigned char curAligned[16]; - + memcpy(curAligned, cur, sizeof(__m128i)); __m128i chunk = _mm_load_si128(reinterpret_cast<const __m128i*>(curAligned)); - + //only ascii characters - simple copy if (!_mm_movemask_epi8(chunk)) { utf16Low = _mm_unpacklo_epi8(chunk, _mm_setzero_si128()); @@ -35,68 +35,68 @@ static Y_FORCE_INLINE ui32 Unpack16BytesIntoUtf16IfNoSurrogats(const unsigned ch cur += 16; return 16; } - + __m128i chunkSigned = _mm_add_epi8(chunk, _mm_set1_epi8(0x80)); __m128i isAsciiMask = _mm_cmpgt_epi8(chunk, _mm_set1_epi8(0)); - + __m128i cond2 = _mm_cmplt_epi8(_mm_set1_epi8(0xc2 - 1 - 0x80), chunkSigned); __m128i state = _mm_set1_epi8(0x0 | (char)0x80); - + __m128i cond3 = _mm_cmplt_epi8(_mm_set1_epi8(0xe0 - 1 - 0x80), chunkSigned); state = _mm_blendv_epi8(state, _mm_set1_epi8(0x2 | (char)0xc0), cond2); - + int sourceAdvance; __m128i shifts; __m128i chunkLow, chunkHigh; - + if (Y_LIKELY(!_mm_movemask_epi8(cond3))) { //main case: no bloks of size 3 or 4 - + //rune len for start of multi-byte sequences (0 for b0... and b10..., 2 for b110..., etc.) __m128i count = _mm_and_si128(state, _mm_set1_epi8(0x7)); - + __m128i countSub1 = _mm_subs_epu8(count, _mm_set1_epi8(0x1)); - + shifts = countSub1; __m128i continuation1 = _mm_slli_si128(countSub1, 1); - + shifts = _mm_add_epi8(shifts, _mm_slli_si128(shifts, 1)); shifts = _mm_add_epi8(shifts, _mm_slli_si128(shifts, 2)); - + __m128i counts = _mm_or_si128(count, continuation1); - + __m128i isBeginMultibyteMask = _mm_cmpgt_epi8(count, _mm_set1_epi8(0)); __m128i needNoContinuationMask = _mm_cmpeq_epi8(continuation1, _mm_set1_epi8(0)); __m128i isBeginMask = _mm_add_epi8(isBeginMultibyteMask, isAsciiMask); //each symbol should be exactly one of ascii, continuation or begin __m128i okMask = _mm_cmpeq_epi8(isBeginMask, needNoContinuationMask); - + if (_mm_movemask_epi8(okMask) != 0xFFFF) { return 0; } - + shifts = _mm_add_epi8(shifts, _mm_slli_si128(shifts, 4)); - + __m128i mask = _mm_and_si128(state, _mm_set1_epi8(0xf8)); shifts = _mm_add_epi8(shifts, _mm_slli_si128(shifts, 8)); - + chunk = _mm_andnot_si128(mask, chunk); // from now on, we only have usefull bits shifts = _mm_and_si128(shifts, _mm_cmplt_epi8(counts, _mm_set1_epi8(2))); // <=1 - + __m128i chunk_right = _mm_slli_si128(chunk, 1); shifts = _mm_blendv_epi8(shifts, _mm_srli_si128(shifts, 1), _mm_srli_si128(_mm_slli_epi16(shifts, 7), 1)); - + chunkLow = _mm_blendv_epi8(chunk, _mm_or_si128(chunk, _mm_and_si128(_mm_slli_epi16(chunk_right, 6), _mm_set1_epi8(0xc0))), _mm_cmpeq_epi8(counts, _mm_set1_epi8(1))); - + chunkHigh = _mm_and_si128(chunk, _mm_cmpeq_epi8(counts, _mm_set1_epi8(2))); - + shifts = _mm_blendv_epi8(shifts, _mm_srli_si128(shifts, 2), _mm_srli_si128(_mm_slli_epi16(shifts, 6), 2)); chunkHigh = _mm_srli_epi32(chunkHigh, 2); - + shifts = _mm_blendv_epi8(shifts, _mm_srli_si128(shifts, 4), _mm_srli_si128(_mm_slli_epi16(shifts, 5), 4)); @@ -166,15 +166,15 @@ static Y_FORCE_INLINE ui32 Unpack16BytesIntoUtf16IfNoSurrogats(const unsigned ch chunkHigh = _mm_or_si128(chunkHigh, _mm_and_si128(_mm_and_si128(_mm_slli_epi32(chunk_right, 4), _mm_set1_epi8(0xf0)), mask3)); - + int c = _mm_extract_epi16(counts, 7); sourceAdvance = !(c & 0x0200) ? 16 : !(c & 0x02) ? 15 : 14; } - + shifts = _mm_blendv_epi8(shifts, _mm_srli_si128(shifts, 8), _mm_srli_si128(_mm_slli_epi16(shifts, 4), 8)); - + chunkHigh = _mm_slli_si128(chunkHigh, 1); __m128i shuf = _mm_add_epi8(shifts, _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)); @@ -206,16 +206,16 @@ namespace NDetail { _mm_store_si128(reinterpret_cast<__m128i*>(destAligned), utf16Low); _mm_store_si128(reinterpret_cast<__m128i*>(destAligned) + 1, utf16High); - memcpy(dest, destAligned, sizeof(__m128i) * 2); + memcpy(dest, destAligned, sizeof(__m128i) * 2); dest += dstAdvance; } //The rest will be handled sequencially. // Possible improvement: go back to the vectorized processing after the error or the 4 byte sequence } - + void UTF8ToWideImplSSE41(const unsigned char*& cur, const unsigned char* last, wchar32*& dest) noexcept { alignas(16) wchar32 destAligned[16]; - + while (cur + 16 <= last) { __m128i utf16Low; __m128i utf16High; @@ -238,10 +238,10 @@ namespace NDetail { memcpy(dest, destAligned, sizeof(__m128i) * 4); dest += dstAdvance; - } - //The rest will be handled sequencially. + } + //The rest will be handled sequencially. // Possible improvement: go back to the vectorized processing after the error or the 4 byte sequence - } -} + } +} #endif diff --git a/util/charset/ya.make b/util/charset/ya.make index 26d38cb10b..e41a9b76e7 100644 --- a/util/charset/ya.make +++ b/util/charset/ya.make @@ -21,13 +21,13 @@ JOIN_SRCS( IF (ARCH_X86_64 AND NOT DISABLE_INSTRUCTION_SETS) SRC_CPP_SSE41(wide_sse41.cpp) -ELSE() +ELSE() SRC( wide_sse41.cpp -DSSE41_STUB ) -ENDIF() - +ENDIF() + END() RECURSE_FOR_TESTS( diff --git a/util/digest/city.h b/util/digest/city.h index 675a798074..aca3e1f8cb 100644 --- a/util/digest/city.h +++ b/util/digest/city.h @@ -3,13 +3,13 @@ #include <util/generic/utility.h> #include <util/generic/strbuf.h> -#include <utility> +#include <utility> // NOTE: These functions provide CityHash 1.0 implementation whose results are *different* from // the mainline version of CityHash. -using uint128 = std::pair<ui64, ui64>; - +using uint128 = std::pair<ui64, ui64>; + constexpr ui64 Uint128Low64(const uint128& x) { return x.first; } diff --git a/util/draft/enum.h b/util/draft/enum.h index 18002b7df2..5c3d202361 100644 --- a/util/draft/enum.h +++ b/util/draft/enum.h @@ -6,7 +6,7 @@ #include <util/stream/str.h> #include <util/string/cast.h> #include <util/string/split.h> -#include <utility> +#include <utility> class TEnumNotFoundException: public yexception { }; @@ -20,7 +20,7 @@ class TEnumNotFoundException: public yexception { #define PrintEnumItems(entries) PrintEnumItemsImpl(entries, Y_ARRAY_SIZE(entries)) template <class K1, class K2, class V> -const V* FindEnumFromStringImpl(K1 key, const std::pair<K2, V>* entries, size_t arraySize) { +const V* FindEnumFromStringImpl(K1 key, const std::pair<K2, V>* entries, size_t arraySize) { for (size_t i = 0; i < arraySize; i++) if (entries[i].first == key) return &entries[i].second; @@ -29,7 +29,7 @@ const V* FindEnumFromStringImpl(K1 key, const std::pair<K2, V>* entries, size_t // special version for const char* template <class V> -const V* FindEnumFromStringImpl(const char* key, const std::pair<const char*, V>* entries, size_t arraySize) { +const V* FindEnumFromStringImpl(const char* key, const std::pair<const char*, V>* entries, size_t arraySize) { for (size_t i = 0; i < arraySize; i++) if (entries[i].first && key && !strcmp(entries[i].first, key)) return &entries[i].second; @@ -56,7 +56,7 @@ TString PrintEnumItemsImpl(const std::pair<const char*, V>* entries, size_t arra } template <class K1, class K2, class V> -const V* EnumFromStringImpl(K1 key, const std::pair<K2, V>* entries, size_t arraySize) { +const V* EnumFromStringImpl(K1 key, const std::pair<K2, V>* entries, size_t arraySize) { const V* res = FindEnumFromStringImpl(key, entries, arraySize); if (res) return res; @@ -65,7 +65,7 @@ const V* EnumFromStringImpl(K1 key, const std::pair<K2, V>* entries, size_t arra } template <class K, class V> -const K* EnumToStringImpl(V value, const std::pair<K, V>* entries, size_t arraySize) { +const K* EnumToStringImpl(V value, const std::pair<K, V>* entries, size_t arraySize) { for (size_t i = 0; i < arraySize; i++) if (entries[i].second == value) return &entries[i].first; @@ -105,7 +105,7 @@ inline void SetEnumFlags(const std::pair<const char*, E> (&str2Enum)[N], TString } template <class E, size_t B> -inline void SetEnumFlags(const std::pair<const char*, E>* str2Enum, TStringBuf optSpec, +inline void SetEnumFlags(const std::pair<const char*, E>* str2Enum, TStringBuf optSpec, std::bitset<B>& flags, const size_t size, bool allIfEmpty = true) { if (optSpec.empty()) { diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h index badfb88993..d4c1c4ac6c 100644 --- a/util/generic/algorithm.h +++ b/util/generic/algorithm.h @@ -9,7 +9,7 @@ #include <numeric> #include <algorithm> #include <iterator> -#include <utility> +#include <utility> namespace NPrivate { template <class I, class F, class P> @@ -656,12 +656,12 @@ static inline auto CountIf(const C& c, P pred) { } template <class I1, class I2> -static inline std::pair<I1, I2> Mismatch(I1 b1, I1 e1, I2 b2) { +static inline std::pair<I1, I2> Mismatch(I1 b1, I1 e1, I2 b2) { return std::mismatch(b1, e1, b2); } template <class I1, class I2, class P> -static inline std::pair<I1, I2> Mismatch(I1 b1, I1 e1, I2 b2, P p) { +static inline std::pair<I1, I2> Mismatch(I1 b1, I1 e1, I2 b2, P p) { return std::mismatch(b1, e1, b2, p); } @@ -677,21 +677,21 @@ static inline void NthElement(RandomIterator begin, RandomIterator nth, RandomIt // no standard implementation until C++14 template <class I1, class I2> -static inline std::pair<I1, I2> Mismatch(I1 b1, I1 e1, I2 b2, I2 e2) { +static inline std::pair<I1, I2> Mismatch(I1 b1, I1 e1, I2 b2, I2 e2) { while (b1 != e1 && b2 != e2 && *b1 == *b2) { ++b1; ++b2; } - return std::make_pair(b1, b2); + return std::make_pair(b1, b2); } template <class I1, class I2, class P> -static inline std::pair<I1, I2> Mismatch(I1 b1, I1 e1, I2 b2, I2 e2, P p) { +static inline std::pair<I1, I2> Mismatch(I1 b1, I1 e1, I2 b2, I2 e2, P p) { while (b1 != e1 && b2 != e2 && p(*b1, *b2)) { ++b1; ++b2; } - return std::make_pair(b1, b2); + return std::make_pair(b1, b2); } template <class It, class Val> @@ -705,12 +705,12 @@ static inline bool BinarySearch(It begin, It end, const Val& val, Comp comp) { } template <class It, class Val> -static inline std::pair<It, It> EqualRange(It begin, It end, const Val& val) { +static inline std::pair<It, It> EqualRange(It begin, It end, const Val& val) { return std::equal_range(begin, end, val); } template <class It, class Val, class Comp> -static inline std::pair<It, It> EqualRange(It begin, It end, const Val& val, Comp comp) { +static inline std::pair<It, It> EqualRange(It begin, It end, const Val& val, Comp comp) { return std::equal_range(begin, end, val, comp); } @@ -745,12 +745,12 @@ TO CopyIf(TI begin, TI end, TO to, P pred) { } template <class T> -std::pair<const T&, const T&> MinMax(const T& first, const T& second) { +std::pair<const T&, const T&> MinMax(const T& first, const T& second) { return std::minmax(first, second); } template <class It> -std::pair<It, It> MinMaxElement(It first, It last) { +std::pair<It, It> MinMaxElement(It first, It last) { return std::minmax_element(first, last); } diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp index 8d732fcc0c..d13cd6b0d9 100644 --- a/util/generic/algorithm_ut.cpp +++ b/util/generic/algorithm_ut.cpp @@ -391,7 +391,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { { int data[] = {1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 5}; - using PairOfInt = std::pair<int*, int*>; + using PairOfInt = std::pair<int*, int*>; PairOfInt tmp = EqualRange(data, data + Y_ARRAY_SIZE(data), 3); UNIT_ASSERT_EQUAL(tmp.second - tmp.first, 4); @@ -603,7 +603,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { } Y_UNIT_TEST(MinMaxTest) { - std::pair<int, int> p1 = MinMax(5, 12); + std::pair<int, int> p1 = MinMax(5, 12); UNIT_ASSERT_EQUAL(p1.first, 5); UNIT_ASSERT_EQUAL(p1.second, 12); diff --git a/util/generic/deque.h b/util/generic/deque.h index 2dabaf3177..4440adb8f2 100644 --- a/util/generic/deque.h +++ b/util/generic/deque.h @@ -15,8 +15,8 @@ class TDeque: public std::deque<T, TReboundAllocator<A, T>> { public: using TBase::TBase; - inline yssize_t ysize() const noexcept { - return (yssize_t)this->size(); + inline yssize_t ysize() const noexcept { + return (yssize_t)this->size(); } inline explicit operator bool() const noexcept { diff --git a/util/generic/hash.h b/util/generic/hash.h index e46db21fa9..fc64dc2c29 100644 --- a/util/generic/hash.h +++ b/util/generic/hash.h @@ -15,7 +15,7 @@ #include <initializer_list> #include <memory> #include <tuple> -#include <utility> +#include <utility> #include <cstdlib> @@ -1027,13 +1027,13 @@ std::pair<typename THashTable<V, K, HF, Ex, Eq, A>::iterator, bool> THashTable<V if (first) /*y*/ for (node* cur = first; !((uintptr_t)cur & 1); cur = cur->next) /*y*/ if (equals(get_key(cur->val), get_key(obj))) - return std::pair<iterator, bool>(iterator(cur), false); /*y*/ + return std::pair<iterator, bool>(iterator(cur), false); /*y*/ node* tmp = new_node(obj); tmp->next = first ? first : (node*)((uintptr_t)&buckets[n + 1] | 1); /*y*/ buckets[n] = tmp; ++num_elements; - return std::pair<iterator, bool>(iterator(tmp), true); /*y*/ + return std::pair<iterator, bool>(iterator(tmp), true); /*y*/ } template <class V, class K, class HF, class Ex, class Eq, class A> @@ -1099,7 +1099,7 @@ __yhashtable_iterator<V> THashTable<V, K, HF, Ex, Eq, A>::find_i(const OtherKey& template <class V, class K, class HF, class Ex, class Eq, class A> template <class OtherKey> std::pair<__yhashtable_iterator<V>, __yhashtable_iterator<V>> THashTable<V, K, HF, Ex, Eq, A>::equal_range(const OtherKey& key) { - using pii = std::pair<iterator, iterator>; + using pii = std::pair<iterator, iterator>; const size_type n = bkt_num_key(key); node* first = buckets[n]; @@ -1122,7 +1122,7 @@ std::pair<__yhashtable_iterator<V>, __yhashtable_iterator<V>> THashTable<V, K, H template <class V, class K, class HF, class Ex, class Eq, class A> template <class OtherKey> std::pair<__yhashtable_const_iterator<V>, __yhashtable_const_iterator<V>> THashTable<V, K, HF, Ex, Eq, A>::equal_range(const OtherKey& key) const { - using pii = std::pair<const_iterator, const_iterator>; + using pii = std::pair<const_iterator, const_iterator>; const size_type n = bkt_num_key(key); const node* first = buckets[n]; @@ -1525,7 +1525,7 @@ public: return rep.size(); } yssize_t ysize() const noexcept { - return (yssize_t)rep.size(); + return (yssize_t)rep.size(); } size_type max_size() const noexcept { return rep.max_size(); @@ -1566,7 +1566,7 @@ public: rep.insert_unique(f, l); } - std::pair<iterator, bool> insert(const value_type& obj) { + std::pair<iterator, bool> insert(const value_type& obj) { return rep.insert_unique(obj); } @@ -1677,12 +1677,12 @@ public: } template <class TKey> - std::pair<iterator, iterator> equal_range(const TKey& key) { + std::pair<iterator, iterator> equal_range(const TKey& key) { return rep.equal_range(key); } template <class TKey> - std::pair<const_iterator, const_iterator> equal_range(const TKey& key) const { + std::pair<const_iterator, const_iterator> equal_range(const TKey& key) const { return rep.equal_range(key); } @@ -1849,8 +1849,8 @@ public: size_type size() const { return rep.size(); } - yssize_t ysize() const { - return (yssize_t)rep.size(); + yssize_t ysize() const { + return (yssize_t)rep.size(); } size_type max_size() const { return rep.max_size(); @@ -1945,12 +1945,12 @@ public: } template <class TKey> - std::pair<iterator, iterator> equal_range(const TKey& key) { + std::pair<iterator, iterator> equal_range(const TKey& key) { return rep.equal_range(key); } template <class TKey> - std::pair<const_iterator, const_iterator> equal_range(const TKey& key) const { + std::pair<const_iterator, const_iterator> equal_range(const TKey& key) const { return rep.equal_range(key); } diff --git a/util/generic/hash_set.h b/util/generic/hash_set.h index e8088cf23b..ea91f3386d 100644 --- a/util/generic/hash_set.h +++ b/util/generic/hash_set.h @@ -4,7 +4,7 @@ #include "hash.h" #include <initializer_list> -#include <utility> +#include <utility> #undef value_type @@ -156,9 +156,9 @@ public: rep.insert_unique(f, l); } - std::pair<iterator, bool> insert(const value_type& obj) { - std::pair<mutable_iterator, bool> p = rep.insert_unique(obj); - return std::pair<iterator, bool>(p.first, p.second); + std::pair<iterator, bool> insert(const value_type& obj) { + std::pair<mutable_iterator, bool> p = rep.insert_unique(obj); + return std::pair<iterator, bool>(p.first, p.second); } template <typename... Args> std::pair<iterator, bool> emplace(Args&&... args) { @@ -167,13 +167,13 @@ public: } iterator insert(const_iterator, const value_type& obj) { // insert_hint - std::pair<mutable_iterator, bool> p = rep.insert_unique(obj); + std::pair<mutable_iterator, bool> p = rep.insert_unique(obj); return p.first; } - std::pair<iterator, bool> insert_noresize(const value_type& obj) { - std::pair<mutable_iterator, bool> p = rep.insert_unique_noresize(obj); - return std::pair<iterator, bool>(p.first, p.second); + std::pair<iterator, bool> insert_noresize(const value_type& obj) { + std::pair<mutable_iterator, bool> p = rep.insert_unique_noresize(obj); + return std::pair<iterator, bool>(p.first, p.second); } template <typename... Args> std::pair<iterator, bool> emplace_noresize(Args&&... args) { @@ -214,7 +214,7 @@ public: } template <class TKey> - std::pair<iterator, iterator> equal_range(const TKey& key) const { + std::pair<iterator, iterator> equal_range(const TKey& key) const { return rep.equal_range(key); } @@ -422,7 +422,7 @@ public: } template <class TKey> - std::pair<iterator, iterator> equal_range(const TKey& key) const { + std::pair<iterator, iterator> equal_range(const TKey& key) const { return rep.equal_range(key); } diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp index 0551d58770..2a7eba2f49 100644 --- a/util/generic/hash_ut.cpp +++ b/util/generic/hash_ut.cpp @@ -295,13 +295,13 @@ void THashTest::TestHMMap1() { mmap m; UNIT_ASSERT(m.count('X') == 0); - m.insert(std::pair<const char, int>('X', 10)); // Standard way. + m.insert(std::pair<const char, int>('X', 10)); // Standard way. UNIT_ASSERT(m.count('X') == 1); - m.insert(std::pair<const char, int>('X', 20)); // jbuck: standard way + m.insert(std::pair<const char, int>('X', 20)); // jbuck: standard way UNIT_ASSERT(m.count('X') == 2); - m.insert(std::pair<const char, int>('Y', 32)); // jbuck: standard way + m.insert(std::pair<const char, int>('Y', 32)); // jbuck: standard way mmap::iterator i = m.find('X'); // Find first match. UNIT_ASSERT((*i).first == 'X'); @@ -358,9 +358,9 @@ void THashTest::TestHMMap1() { void THashTest::TestHMMapHas() { using mmap = THashMultiMap<char, int, THash<char>, TEqualTo<char>>; mmap m; - m.insert(std::pair<const char, int>('X', 10)); - m.insert(std::pair<const char, int>('X', 20)); - m.insert(std::pair<const char, int>('Y', 32)); + m.insert(std::pair<const char, int>('X', 10)); + m.insert(std::pair<const char, int>('X', 20)); + m.insert(std::pair<const char, int>('Y', 32)); UNIT_ASSERT(m.contains('X')); UNIT_ASSERT(m.contains('Y')); UNIT_ASSERT(!m.contains('Z')); diff --git a/util/generic/list.h b/util/generic/list.h index 7b0b8ffc72..8dac504e96 100644 --- a/util/generic/list.h +++ b/util/generic/list.h @@ -7,7 +7,7 @@ #include <initializer_list> #include <list> #include <memory> -#include <utility> +#include <utility> template <class T, class A> class TList: public std::list<T, TReboundAllocator<A, T>> { diff --git a/util/generic/map.h b/util/generic/map.h index b5001b56c0..39df17b785 100644 --- a/util/generic/map.h +++ b/util/generic/map.h @@ -6,7 +6,7 @@ #include <util/str_stl.h> #include <util/memory/alloc.h> -#include <utility> +#include <utility> #include <initializer_list> #include <map> #include <memory> diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp index 79e832b024..14eb085bc3 100644 --- a/util/generic/map_ut.cpp +++ b/util/generic/map_ut.cpp @@ -51,14 +51,14 @@ Y_UNIT_TEST_SUITE(TYMapTest) { UNIT_ASSERT(m.count('z') == 1); - std::pair<typename maptype::iterator, bool> p = m.insert(std::pair<const char, int>('c', 100)); + std::pair<typename maptype::iterator, bool> p = m.insert(std::pair<const char, int>('c', 100)); UNIT_ASSERT(p.second); UNIT_ASSERT(p.first != m.end()); UNIT_ASSERT((*p.first).first == 'c'); UNIT_ASSERT((*p.first).second == 100); - p = m.insert(std::pair<const char, int>('c', 100)); + p = m.insert(std::pair<const char, int>('c', 100)); UNIT_ASSERT(!p.second); // already existing pair UNIT_ASSERT(p.first != m.end()); @@ -72,13 +72,13 @@ Y_UNIT_TEST_SUITE(TYMapTest) { UNIT_ASSERT(m.count('X') == 0); - m.insert(std::pair<const char, int>('X', 10)); // Standard way. + m.insert(std::pair<const char, int>('X', 10)); // Standard way. UNIT_ASSERT(m.count('X') == 1); - m.insert(std::pair<const char, int>('X', 20)); // jbuck: standard way + m.insert(std::pair<const char, int>('X', 20)); // jbuck: standard way UNIT_ASSERT(m.count('X') == 2); - m.insert(std::pair<const char, int>('Y', 32)); // jbuck: standard way + m.insert(std::pair<const char, int>('Y', 32)); // jbuck: standard way typename mmap::iterator i = m.find('X'); // Find first match. ++i; UNIT_ASSERT((*i).first == 'X'); @@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { } Y_UNIT_TEST(TestMMap2) { - using pair_type = std::pair<const int, char>; + using pair_type = std::pair<const int, char>; pair_type p1(3, 'c'); pair_type p2(6, 'f'); @@ -194,7 +194,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { maptype m; m['x'] = 10; - std::pair<maptype::iterator, maptype::iterator> ret; + std::pair<maptype::iterator, maptype::iterator> ret; ret = m.equal_range('x'); UNIT_ASSERT(ret.first != ret.second); UNIT_ASSERT((*(ret.first)).first == 'x'); @@ -212,7 +212,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { i = m.upper_bound('x'); UNIT_ASSERT(i == m.end()); - std::pair<maptype::iterator, maptype::iterator> ret; + std::pair<maptype::iterator, maptype::iterator> ret; ret = m.equal_range('x'); UNIT_ASSERT(ret.first == ret.second); UNIT_ASSERT(ret.first == m.end()); @@ -220,7 +220,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { { const maptype m; - std::pair<maptype::const_iterator, maptype::const_iterator> ret; + std::pair<maptype::const_iterator, maptype::const_iterator> ret; ret = m.equal_range('x'); UNIT_ASSERT(ret.first == ret.second); UNIT_ASSERT(ret.first == m.end()); @@ -357,7 +357,7 @@ Y_UNIT_TEST_SUITE(TYMapTest) { UNIT_ASSERT(ccont.find(2) != ccont.end()); UNIT_ASSERT(ccont.lower_bound(2) != ccont.end()); UNIT_ASSERT(ccont.upper_bound(2) != ccont.end()); - UNIT_ASSERT(ccont.equal_range(2) != std::make_pair(ccont.end(), ccont.end())); + UNIT_ASSERT(ccont.equal_range(2) != std::make_pair(ccont.end(), ccont.end())); } { @@ -430,9 +430,9 @@ Y_UNIT_TEST_SUITE(TYMapTest) { Container c(direct); c = Container(inverse); - c.insert(std::make_pair(TKey(1), 101)); - c.insert(std::make_pair(TKey(2), 102)); - c.insert(std::make_pair(TKey(3), 103)); + c.insert(std::make_pair(TKey(1), 101)); + c.insert(std::make_pair(TKey(2), 102)); + c.insert(std::make_pair(TKey(3), 103)); TVector<int> values; for (auto& i : c) { diff --git a/util/generic/set_ut.cpp b/util/generic/set_ut.cpp index d2769d327f..fe51cc44c0 100644 --- a/util/generic/set_ut.cpp +++ b/util/generic/set_ut.cpp @@ -23,7 +23,7 @@ Y_UNIT_TEST_SUITE(YSetTest) { Y_UNIT_TEST(TestSet2) { using int_set = TSet<int, TLess<int>>; int_set s; - std::pair<int_set::iterator, bool> p = s.insert(42); + std::pair<int_set::iterator, bool> p = s.insert(42); UNIT_ASSERT(p.second == true); p = s.insert(42); UNIT_ASSERT(p.second == false); diff --git a/util/generic/typetraits.h b/util/generic/typetraits.h index d165bd1a06..604d2591a4 100644 --- a/util/generic/typetraits.h +++ b/util/generic/typetraits.h @@ -6,7 +6,7 @@ #include <iterator> #include <type_traits> -#include <stlfwd> +#include <stlfwd> #if _LIBCPP_STD_VER >= 17 template <bool B> @@ -228,12 +228,12 @@ class TTypeTraits<void>: public TTypeTraitsBase<void> {}; */ #define Y_HAS_SUBTYPE(...) Y_PASS_VA_ARGS(Y_MACRO_IMPL_DISPATCHER_2(__VA_ARGS__, Y_HAS_SUBTYPE_IMPL_2, Y_HAS_SUBTYPE_IMPL_1)(__VA_ARGS__)) -template <class T1, class T2> -struct TPodTraits<std::pair<T1, T2>> { - enum { - IsPod = TTypeTraits<T1>::IsPod && TTypeTraits<T2>::IsPod - }; -}; +template <class T1, class T2> +struct TPodTraits<std::pair<T1, T2>> { + enum { + IsPod = TTypeTraits<T1>::IsPod && TTypeTraits<T2>::IsPod + }; +}; template <class T> struct TIsPointerToConstMemberFunction: std::false_type { diff --git a/util/generic/vector.h b/util/generic/vector.h index a5b258955a..4f9e7f715e 100644 --- a/util/generic/vector.h +++ b/util/generic/vector.h @@ -106,8 +106,8 @@ public: return TBase::empty(); } - inline yssize_t ysize() const noexcept { - return (yssize_t)TBase::size(); + inline yssize_t ysize() const noexcept { + return (yssize_t)TBase::size(); } #ifdef _YNDX_LIBCXX_ENABLE_VECTOR_POD_RESIZE_UNINITIALIZED diff --git a/util/str_stl.h b/util/str_stl.h index f1e137181d..a91846292e 100644 --- a/util/str_stl.h +++ b/util/str_stl.h @@ -9,7 +9,7 @@ #include <functional> #include <typeindex> -#include <utility> +#include <utility> namespace std { template <> diff --git a/util/system/fasttime.cpp b/util/system/fasttime.cpp index 057a814f0a..4d40a42d63 100644 --- a/util/system/fasttime.cpp +++ b/util/system/fasttime.cpp @@ -3,7 +3,7 @@ #include <util/generic/singleton.h> #include <util/generic/yexception.h> -#include <utility> +#include <utility> #include <util/thread/singleton.h> @@ -121,7 +121,7 @@ namespace { template <size_t N, class A, class B> class TLinePredictor { public: - using TSample = std::pair<A, B>; + using TSample = std::pair<A, B>; inline TLinePredictor() : C_(0) diff --git a/util/system/thread.cpp b/util/system/thread.cpp index 6236746c2d..86762e3286 100644 --- a/util/system/thread.cpp +++ b/util/system/thread.cpp @@ -7,7 +7,7 @@ #include <util/generic/ylimits.h> #include <util/generic/yexception.h> #include "yassert.h" -#include <utility> +#include <utility> #if defined(_glibc_) #if !__GLIBC_PREREQ(2, 30) diff --git a/util/system/tls.cpp b/util/system/tls.cpp index c2f1a04a14..9de07d366d 100644 --- a/util/system/tls.cpp +++ b/util/system/tls.cpp @@ -243,8 +243,8 @@ TKey::TKey(TDtor dtor) { } -TKey::TKey(TKey&&) noexcept = default; - +TKey::TKey(TKey&&) noexcept = default; + TKey::~TKey() = default; void* TKey::Get() const { diff --git a/util/system/tls.h b/util/system/tls.h index 3c4f56dbeb..7539dcb35e 100644 --- a/util/system/tls.h +++ b/util/system/tls.h @@ -157,7 +157,7 @@ namespace NTls { class TKey { public: TKey(TDtor dtor); - TKey(TKey&&) noexcept; + TKey(TKey&&) noexcept; ~TKey(); void* Get() const; @@ -177,7 +177,7 @@ namespace NTls { }; template <class T> - class TValue: public TMoveOnly { + class TValue: public TMoveOnly { class TConstructor { public: TConstructor() noexcept = default; diff --git a/util/system/types.h b/util/system/types.h index 12e68a6060..4955fbb3bb 100644 --- a/util/system/types.h +++ b/util/system/types.h @@ -11,9 +11,9 @@ typedef int16_t i16; typedef uint8_t ui8; typedef uint16_t ui16; -typedef int yssize_t; -#define PRIYSZT "d" - +typedef int yssize_t; +#define PRIYSZT "d" + #if defined(_darwin_) && defined(_32_) typedef unsigned long ui32; typedef long i32; |