diff options
author | breakneck <breakneck@yandex-team.ru> | 2022-02-10 16:47:58 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:58 +0300 |
commit | e2021f9a0e54d13b7c48796318b13b66dc625e74 (patch) | |
tree | 5aed1691033eaf399ab80a10a137238922035fa8 /util | |
parent | 83602b1b564b92a80a1526d113fa2846661dd10e (diff) | |
download | ydb-e2021f9a0e54d13b7c48796318b13b66dc625e74.tar.gz |
Restoring authorship annotation for <breakneck@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r-- | util/charset/wide.h | 28 | ||||
-rw-r--r-- | util/charset/wide_specific.h | 44 | ||||
-rw-r--r-- | util/charset/wide_ut.cpp | 2 | ||||
-rw-r--r-- | util/digest/murmur.h | 22 | ||||
-rw-r--r-- | util/digest/murmur_ut.cpp | 28 | ||||
-rw-r--r-- | util/digest/sequence.h | 90 | ||||
-rw-r--r-- | util/digest/sequence_ut.cpp | 84 | ||||
-rw-r--r-- | util/digest/ut/ya.make | 2 | ||||
-rw-r--r-- | util/folder/path.cpp | 2 | ||||
-rw-r--r-- | util/generic/array_ref.h | 2 | ||||
-rw-r--r-- | util/generic/bitmap.h | 116 | ||||
-rw-r--r-- | util/generic/bitops.h | 44 | ||||
-rw-r--r-- | util/generic/flags.h | 8 | ||||
-rw-r--r-- | util/generic/hash_ut.cpp | 44 | ||||
-rw-r--r-- | util/generic/string.h | 4 | ||||
-rw-r--r-- | util/str_stl.h | 56 | ||||
-rw-r--r-- | util/system/compiler.h | 4 | ||||
-rw-r--r-- | util/system/defaults.h | 2 | ||||
-rw-r--r-- | util/system/file.cpp | 4 | ||||
-rw-r--r-- | util/system/file.h | 10 |
20 files changed, 298 insertions, 298 deletions
diff --git a/util/charset/wide.h b/util/charset/wide.h index 04e6928aab..2d28f33d24 100644 --- a/util/charset/wide.h +++ b/util/charset/wide.h @@ -52,8 +52,8 @@ namespace NDetail { wchar16 lead = chars[0]; wchar16 tail = chars[1]; - Y_ASSERT(IsW16SurrogateLead(lead)); - Y_ASSERT(IsW16SurrogateTail(tail)); + Y_ASSERT(IsW16SurrogateLead(lead)); + Y_ASSERT(IsW16SurrogateTail(tail)); return (static_cast<wchar32>(lead) << 10) + tail + SURROGATE_OFFSET; } @@ -64,10 +64,10 @@ namespace NDetail { } inline wchar16* SkipSymbol(wchar16* begin, const wchar16* end) noexcept { - return begin + W16SymbolSize(begin, end); + return begin + W16SymbolSize(begin, end); } inline const wchar16* SkipSymbol(const wchar16* begin, const wchar16* end) noexcept { - return begin + W16SymbolSize(begin, end); + return begin + W16SymbolSize(begin, end); } inline wchar32* SkipSymbol(wchar32* begin, const wchar32* end) noexcept { Y_ASSERT(begin < end); @@ -80,12 +80,12 @@ inline const wchar32* SkipSymbol(const wchar32* begin, const wchar32* end) noexc inline wchar32 ReadSymbol(const wchar16* begin, const wchar16* end) noexcept { Y_ASSERT(begin < end); - if (IsW16SurrogateLead(*begin)) { + if (IsW16SurrogateLead(*begin)) { if (begin + 1 < end && IsW16SurrogateTail(*(begin + 1))) return ::NDetail::ReadSurrogatePair(begin); return BROKEN_RUNE; - } else if (IsW16SurrogateTail(*begin)) { + } else if (IsW16SurrogateTail(*begin)) { return BROKEN_RUNE; } @@ -100,8 +100,8 @@ inline wchar32 ReadSymbol(const wchar32* begin, const wchar32* end) noexcept { //! presuming input data is either big enought of null terminated inline wchar32 ReadSymbolAndAdvance(const wchar16*& begin) noexcept { Y_ASSERT(*begin); - if (IsW16SurrogateLead(begin[0])) { - if (IsW16SurrogateTail(begin[1])) { + if (IsW16SurrogateLead(begin[0])) { + if (IsW16SurrogateTail(begin[1])) { Y_ASSERT(begin[1] != 0); const wchar32 c = ::NDetail::ReadSurrogatePair(begin); begin += 2; @@ -109,7 +109,7 @@ inline wchar32 ReadSymbolAndAdvance(const wchar16*& begin) noexcept { } ++begin; return BROKEN_RUNE; - } else if (IsW16SurrogateTail(begin[0])) { + } else if (IsW16SurrogateTail(begin[0])) { ++begin; return BROKEN_RUNE; } @@ -124,15 +124,15 @@ inline wchar32 ReadSymbolAndAdvance(const wchar32*& begin) noexcept { inline wchar32 ReadSymbolAndAdvance(const wchar16*& begin, const wchar16* end) noexcept { Y_ASSERT(begin < end); - if (IsW16SurrogateLead(begin[0])) { - if (begin + 1 != end && IsW16SurrogateTail(begin[1])) { + if (IsW16SurrogateLead(begin[0])) { + if (begin + 1 != end && IsW16SurrogateTail(begin[1])) { const wchar32 c = ::NDetail::ReadSurrogatePair(begin); begin += 2; return c; } ++begin; return BROKEN_RUNE; - } else if (IsW16SurrogateTail(begin[0])) { + } else if (IsW16SurrogateTail(begin[0])) { ++begin; return BROKEN_RUNE; } @@ -204,8 +204,8 @@ inline void ::NDetail::WriteSurrogatePair(wchar32 s, T& dest) noexcept { wchar16 lead = LEAD_OFFSET + (static_cast<wchar16>(s >> 10)); wchar16 tail = 0xDC00 + static_cast<wchar16>(s & 0x3FF); - Y_ASSERT(IsW16SurrogateLead(lead)); - Y_ASSERT(IsW16SurrogateTail(tail)); + Y_ASSERT(IsW16SurrogateLead(lead)); + Y_ASSERT(IsW16SurrogateTail(tail)); WriteSymbol(lead, dest); WriteSymbol(tail, dest); diff --git a/util/charset/wide_specific.h b/util/charset/wide_specific.h index 4ea765b94b..983bf55341 100644 --- a/util/charset/wide_specific.h +++ b/util/charset/wide_specific.h @@ -1,22 +1,22 @@ -#pragma once - -#include <util/system/types.h> -#include <util/system/yassert.h> - -inline constexpr bool IsW16SurrogateLead(wchar16 c) noexcept { - return 0xD800 <= c && c <= 0xDBFF; -} - -inline constexpr bool IsW16SurrogateTail(wchar16 c) noexcept { - return 0xDC00 <= c && c <= 0xDFFF; -} - -inline size_t W16SymbolSize(const wchar16* begin, const wchar16* end) { - Y_ASSERT(begin < end); - - if ((begin + 1 != end) && IsW16SurrogateLead(*begin) && IsW16SurrogateTail(*(begin + 1))) { - return 2; - } - - return 1; -} +#pragma once + +#include <util/system/types.h> +#include <util/system/yassert.h> + +inline constexpr bool IsW16SurrogateLead(wchar16 c) noexcept { + return 0xD800 <= c && c <= 0xDBFF; +} + +inline constexpr bool IsW16SurrogateTail(wchar16 c) noexcept { + return 0xDC00 <= c && c <= 0xDFFF; +} + +inline size_t W16SymbolSize(const wchar16* begin, const wchar16* end) { + Y_ASSERT(begin < end); + + if ((begin + 1 != end) && IsW16SurrogateLead(*begin) && IsW16SurrogateTail(*(begin + 1))) { + return 2; + } + + return 1; +} diff --git a/util/charset/wide_ut.cpp b/util/charset/wide_ut.cpp index d8f3233e73..7c8e5ffe6b 100644 --- a/util/charset/wide_ut.cpp +++ b/util/charset/wide_ut.cpp @@ -575,7 +575,7 @@ void TConversionTest::TestUnicodeDetails() { for (wchar32 i = 0; i != NUnicode::UnicodeInstancesLimit(); ++i) { temp.clear(); WriteSymbol(i, temp); - UNIT_ASSERT(temp.size() == W16SymbolSize(temp.c_str(), temp.c_str() + temp.size())); + UNIT_ASSERT(temp.size() == W16SymbolSize(temp.c_str(), temp.c_str() + temp.size())); } } diff --git a/util/digest/murmur.h b/util/digest/murmur.h index 6b519b430a..0c3c8d3dbb 100644 --- a/util/digest/murmur.h +++ b/util/digest/murmur.h @@ -1,7 +1,7 @@ #pragma once #include <util/system/defaults.h> -#include <util/generic/array_ref.h> +#include <util/generic/array_ref.h> /* * murmur2 from http://murmurhash.googlepages.com/ @@ -41,15 +41,15 @@ static inline T MurmurHash(const void* buf, size_t len) noexcept { //non-inline version size_t MurmurHashSizeT(const char* buf, size_t len) noexcept; - -template <typename TOut = size_t> -struct TMurmurHash { + +template <typename TOut = size_t> +struct TMurmurHash { TOut operator()(const void* buf, size_t len) const noexcept { - return MurmurHash<TOut>(buf, len); - } - - template <typename ElementType> + return MurmurHash<TOut>(buf, len); + } + + template <typename ElementType> TOut operator()(const TArrayRef<ElementType>& data) const noexcept { - return operator()(data.data(), data.size() * sizeof(ElementType)); - } -}; + return operator()(data.data(), data.size() * sizeof(ElementType)); + } +}; diff --git a/util/digest/murmur_ut.cpp b/util/digest/murmur_ut.cpp index 29287668bc..4f763ba366 100644 --- a/util/digest/murmur_ut.cpp +++ b/util/digest/murmur_ut.cpp @@ -9,7 +9,7 @@ class TMurmurHashTest: public TTestBase { UNIT_TEST(TestUnalignedHash32) UNIT_TEST(TestHash64) UNIT_TEST(TestUnalignedHash64) - UNIT_TEST(TestWrapperBiggerTypes) + UNIT_TEST(TestWrapperBiggerTypes) UNIT_TEST_SUITE_END(); private: @@ -21,7 +21,7 @@ private: } Test<ui32>(buf, 256, 2373126550UL); - TestWrapper<ui8, ui32>({buf, buf + 256}, 2373126550UL); + TestWrapper<ui8, ui32>({buf, buf + 256}, 2373126550UL); Test<ui32>(buf, 255, 3301607533UL); Test<ui32>(buf, 254, 2547410121UL); Test<ui32>(buf, 253, 80030810UL); @@ -46,7 +46,7 @@ private: } Test<ui64>(buf, 256, ULL(12604435678857905857)); - TestWrapper<ui8, ui64>({buf, buf + 256}, ULL(12604435678857905857)); + TestWrapper<ui8, ui64>({buf, buf + 256}, ULL(12604435678857905857)); Test<ui64>(buf, 255, ULL(1708835094528446095)); Test<ui64>(buf, 254, ULL(5077937678736514994)); Test<ui64>(buf, 253, ULL(11553864555081396353)); @@ -63,23 +63,23 @@ private: Test<ui64>(unalignedBuf, 256, ULL(12604435678857905857)); } - inline void TestWrapperBiggerTypes() { - ui32 buf[] = {24, 42}; - TestWrapper<ui32, ui32>({buf, buf + 2}, MurmurHash<ui32>(buf, sizeof(ui32) * 2)); - TestWrapper<ui32, ui64>({buf, buf + 2}, MurmurHash<ui64>(buf, sizeof(ui32) * 2)); - } - + inline void TestWrapperBiggerTypes() { + ui32 buf[] = {24, 42}; + TestWrapper<ui32, ui32>({buf, buf + 2}, MurmurHash<ui32>(buf, sizeof(ui32) * 2)); + TestWrapper<ui32, ui64>({buf, buf + 2}, MurmurHash<ui64>(buf, sizeof(ui32) * 2)); + } + private: template <class T> inline void Test(const void* data, size_t len, T expected) { UNIT_ASSERT_STRINGS_EQUAL(ToString(MurmurHash<T>(data, len)), ToString(expected)); } - - template <class E, class T> + + template <class E, class T> inline void TestWrapper(const TArrayRef<E>& array, T expected) { - auto val = TMurmurHash<T>()(array); - UNIT_ASSERT_EQUAL(val, expected); - } + auto val = TMurmurHash<T>()(array); + UNIT_ASSERT_EQUAL(val, expected); + } }; UNIT_TEST_SUITE_REGISTRATION(TMurmurHashTest); diff --git a/util/digest/sequence.h b/util/digest/sequence.h index 712331007b..a8a1bce688 100644 --- a/util/digest/sequence.h +++ b/util/digest/sequence.h @@ -1,48 +1,48 @@ -#pragma once - -#include "numeric.h" -#include <util/generic/hash.h> -#include <util/generic/array_ref.h> - -template <typename ElementHash = void> -class TRangeHash { -private: - template <typename ElementType> - using TBase = std::conditional_t< - !std::is_void<ElementHash>::value, - ElementHash, +#pragma once + +#include "numeric.h" +#include <util/generic/hash.h> +#include <util/generic/array_ref.h> + +template <typename ElementHash = void> +class TRangeHash { +private: + template <typename ElementType> + using TBase = std::conditional_t< + !std::is_void<ElementHash>::value, + ElementHash, THash<ElementType>>; - -public: - template <typename Range> - size_t operator()(const Range& range) const { - size_t accumulated = 0; - for (const auto& element : range) { - accumulated = CombineHashes(accumulated, TBase<typename Range::value_type>()(element)); - } - return accumulated; - } -}; - -using TSimpleRangeHash = TRangeHash<>; - -template <typename RegionHash = void> -class TContiguousHash { -private: - template <typename ElementType> - using TBase = std::conditional_t< - !std::is_void<RegionHash>::value, - RegionHash, + +public: + template <typename Range> + size_t operator()(const Range& range) const { + size_t accumulated = 0; + for (const auto& element : range) { + accumulated = CombineHashes(accumulated, TBase<typename Range::value_type>()(element)); + } + return accumulated; + } +}; + +using TSimpleRangeHash = TRangeHash<>; + +template <typename RegionHash = void> +class TContiguousHash { +private: + template <typename ElementType> + using TBase = std::conditional_t< + !std::is_void<RegionHash>::value, + RegionHash, TRangeHash<ElementType>>; - -public: - template <typename ContainerType> - auto operator()(const ContainerType& container) const { - return operator()(MakeArrayRef(container)); - } - - template <typename ElementType> + +public: + template <typename ContainerType> + auto operator()(const ContainerType& container) const { + return operator()(MakeArrayRef(container)); + } + + template <typename ElementType> auto operator()(const TArrayRef<ElementType>& data) const { - return TBase<ElementType>()(data); - } -}; + return TBase<ElementType>()(data); + } +}; diff --git a/util/digest/sequence_ut.cpp b/util/digest/sequence_ut.cpp index 87d6102ee5..f49ebc9638 100644 --- a/util/digest/sequence_ut.cpp +++ b/util/digest/sequence_ut.cpp @@ -1,62 +1,62 @@ -#include "sequence.h" - +#include "sequence.h" + #include <library/cpp/testing/unittest/registar.h> #include <util/generic/map.h> -#include <util/generic/vector.h> - -class TRangeHashTest: public TTestBase { - UNIT_TEST_SUITE(TRangeHashTest); - UNIT_TEST(TestStrokaInt) - UNIT_TEST(TestIntVector) - UNIT_TEST(TestOneElement) +#include <util/generic/vector.h> + +class TRangeHashTest: public TTestBase { + UNIT_TEST_SUITE(TRangeHashTest); + UNIT_TEST(TestStrokaInt) + UNIT_TEST(TestIntVector) + UNIT_TEST(TestOneElement) UNIT_TEST(TestMap); - UNIT_TEST(TestCollectionIndependancy); - UNIT_TEST_SUITE_END(); - -private: - inline void TestStrokaInt() { + UNIT_TEST(TestCollectionIndependancy); + UNIT_TEST_SUITE_END(); + +private: + inline void TestStrokaInt() { const size_t canonicalHash = static_cast<size_t>(ULL(12727184940294366172)); UNIT_ASSERT_EQUAL(canonicalHash, TRangeHash<>()(TString("12345"))); - } - - inline void TestIntVector() { + } + + inline void TestIntVector() { const size_t canonicalHash = static_cast<size_t>(ULL(1351128487744230578)); TVector<int> testVec = {1, 2, 4, 3}; - UNIT_ASSERT_EQUAL(canonicalHash, TRangeHash<>()(testVec)); - } - - inline void TestOneElement() { - const int testVal = 42; + UNIT_ASSERT_EQUAL(canonicalHash, TRangeHash<>()(testVec)); + } + + inline void TestOneElement() { + const int testVal = 42; TVector<int> testVec = {testVal}; - UNIT_ASSERT_UNEQUAL(THash<int>()(testVal), TRangeHash<>()(testVec)); - } - + UNIT_ASSERT_UNEQUAL(THash<int>()(testVal), TRangeHash<>()(testVec)); + } + inline void TestMap() { const size_t canonicalHash = static_cast<size_t>(ULL(4415387926488545605)); TMap<TString, int> testMap{{"foo", 123}, {"bar", 456}}; UNIT_ASSERT_EQUAL(canonicalHash, TRangeHash<>()(testMap)); } - inline void TestCollectionIndependancy() { + inline void TestCollectionIndependancy() { TVector<char> testVec = {'a', 'b', 'c'}; TString testStroka = "abc"; - UNIT_ASSERT_EQUAL(TRangeHash<>()(testVec), TRangeHash<>()(testStroka)); - } -}; - + UNIT_ASSERT_EQUAL(TRangeHash<>()(testVec), TRangeHash<>()(testStroka)); + } +}; + class TSequenceHashTest: public TTestBase { - UNIT_TEST_SUITE(TSequenceHashTest); - UNIT_TEST(TestSimpleBuffer) - UNIT_TEST_SUITE_END(); + UNIT_TEST_SUITE(TSequenceHashTest); + UNIT_TEST(TestSimpleBuffer) + UNIT_TEST_SUITE_END(); -private: - inline void TestSimpleBuffer() { - int arr[] = {1, 2, 3}; +private: + inline void TestSimpleBuffer() { + int arr[] = {1, 2, 3}; const size_t canonicalHash = static_cast<size_t>(ULL(3903918011533391876)); - TContiguousHash<TSimpleRangeHash> hasher; + TContiguousHash<TSimpleRangeHash> hasher; UNIT_ASSERT_EQUAL(canonicalHash, hasher(TArrayRef<int>(arr, arr + 3))); - } -}; - -UNIT_TEST_SUITE_REGISTRATION(TRangeHashTest); -UNIT_TEST_SUITE_REGISTRATION(TSequenceHashTest); + } +}; + +UNIT_TEST_SUITE_REGISTRATION(TRangeHashTest); +UNIT_TEST_SUITE_REGISTRATION(TSequenceHashTest); diff --git a/util/digest/ut/ya.make b/util/digest/ut/ya.make index 245b2cf6d2..25d2f50ba3 100644 --- a/util/digest/ut/ya.make +++ b/util/digest/ut/ya.make @@ -7,7 +7,7 @@ SRCS( digest/fnv_ut.cpp digest/murmur_ut.cpp digest/multi_ut.cpp - digest/sequence_ut.cpp + digest/sequence_ut.cpp ) INCLUDE(${ARCADIA_ROOT}/util/tests/ya_util_tests.inc) diff --git a/util/folder/path.cpp b/util/folder/path.cpp index bfe0c67d68..39b01401b4 100644 --- a/util/folder/path.cpp +++ b/util/folder/path.cpp @@ -186,7 +186,7 @@ TFsPath::TSplit& TFsPath::GetSplit() const { return *Split_; } -static Y_FORCE_INLINE void VerifyPath(const TStringBuf path) { +static Y_FORCE_INLINE void VerifyPath(const TStringBuf path) { Y_VERIFY(!path.Contains('\0'), "wrong format of TFsPath"); } diff --git a/util/generic/array_ref.h b/util/generic/array_ref.h index 1ac60ac7d3..7ba6fc71bf 100644 --- a/util/generic/array_ref.h +++ b/util/generic/array_ref.h @@ -72,7 +72,7 @@ public: , S_(N) { } - + template <class TT, typename = std::enable_if_t<std::is_same<std::remove_const_t<T>, std::remove_const_t<TT>>::value>> bool operator==(const TArrayRef<TT>& other) const noexcept { return (S_ == other.size()) && std::equal(begin(), end(), other.begin()); diff --git a/util/generic/bitmap.h b/util/generic/bitmap.h index f77d182460..42d2c6e704 100644 --- a/util/generic/bitmap.h +++ b/util/generic/bitmap.h @@ -174,7 +174,7 @@ namespace NBitMapPrivate { CopyData(Data, Size, data, size); } - Y_FORCE_INLINE void Swap(TFixedStorage<BitCount, TChunkType>& st) { + Y_FORCE_INLINE void Swap(TFixedStorage<BitCount, TChunkType>& st) { for (size_t i = 0; i < Size; ++i) { DoSwap(Data[i], st.Data[i]); } @@ -193,7 +193,7 @@ namespace NBitMapPrivate { return bitSize <= BitCount; } - Y_FORCE_INLINE void Sanitize() { + Y_FORCE_INLINE void Sanitize() { Data[Size - 1] &= TSanitizeMask<TChunk, BitCount % (8 * sizeof(TChunk))>::Value; } }; @@ -240,7 +240,7 @@ namespace NBitMapPrivate { CopyData(Data, Size, data, size); } - Y_FORCE_INLINE void Swap(TDynamicStorage<TChunkType>& st) { + Y_FORCE_INLINE void Swap(TDynamicStorage<TChunkType>& st) { DoSwap(Size, st.Size); DoSwap(StackData, st.StackData); DoSwap(ArrayData, st.ArrayData); @@ -248,16 +248,16 @@ namespace NBitMapPrivate { st.Data = 1 == st.Size ? &st.StackData : st.ArrayData.Get(); } - Y_FORCE_INLINE size_t GetBitCapacity() const { + Y_FORCE_INLINE size_t GetBitCapacity() const { return Size * 8 * sizeof(TChunk); } - Y_FORCE_INLINE size_t GetChunkCapacity() const { + Y_FORCE_INLINE size_t GetChunkCapacity() const { return Size; } // Returns true if the resulting storage capacity is enough to fit the requested size - Y_FORCE_INLINE bool ExpandSize(size_t size, bool keepData = true) { + Y_FORCE_INLINE bool ExpandSize(size_t size, bool keepData = true) { if (size > Size) { size = Max(size, Size * 2); TArrayHolder<TChunk> newData(new TChunk[size]); @@ -276,11 +276,11 @@ namespace NBitMapPrivate { return true; } - Y_FORCE_INLINE bool ExpandBitSize(size_t bitSize, bool keepData = true) { + Y_FORCE_INLINE bool ExpandBitSize(size_t bitSize, bool keepData = true) { return ExpandSize((bitSize + 8 * sizeof(TChunk) - 1) / (8 * sizeof(TChunk)), keepData); } - Y_FORCE_INLINE void Sanitize() { + Y_FORCE_INLINE void Sanitize() { } }; @@ -349,7 +349,7 @@ public: public: ~TReference() = default; - Y_FORCE_INLINE TReference& operator=(bool val) { + Y_FORCE_INLINE TReference& operator=(bool val) { if (val) *Chunk |= static_cast<TChunk>(1) << Offset; else @@ -358,7 +358,7 @@ public: return *this; } - Y_FORCE_INLINE TReference& operator=(const TReference& ref) { + Y_FORCE_INLINE TReference& operator=(const TReference& ref) { if (ref) *Chunk |= static_cast<TChunk>(1) << Offset; else @@ -367,15 +367,15 @@ public: return *this; } - Y_FORCE_INLINE bool operator~() const { + Y_FORCE_INLINE bool operator~() const { return 0 == (*Chunk & (static_cast<TChunk>(1) << Offset)); } - Y_FORCE_INLINE operator bool() const { + Y_FORCE_INLINE operator bool() const { return 0 != (*Chunk & (static_cast<TChunk>(1) << Offset)); } - Y_FORCE_INLINE TReference& Flip() { + Y_FORCE_INLINE TReference& Flip() { *Chunk ^= static_cast<TChunk>(1) << Offset; return *this; } @@ -433,11 +433,11 @@ public: } template <class T> - Y_FORCE_INLINE bool operator==(const TBitMapOps<T>& bitmap) const { + Y_FORCE_INLINE bool operator==(const TBitMapOps<T>& bitmap) const { return Equal(bitmap); } - Y_FORCE_INLINE TThis& operator=(const TThis& bitmap) { + Y_FORCE_INLINE TThis& operator=(const TThis& bitmap) { if (this != &bitmap) { TThis bm(bitmap); Swap(bm); @@ -446,79 +446,79 @@ public: } template <class T> - Y_FORCE_INLINE TThis& operator=(const TBitMapOps<T>& bitmap) { + Y_FORCE_INLINE TThis& operator=(const TBitMapOps<T>& bitmap) { TThis bm(bitmap); Swap(bm); return *this; } template <class T> - Y_FORCE_INLINE TThis& operator&=(const TBitMapOps<T>& bitmap) { + Y_FORCE_INLINE TThis& operator&=(const TBitMapOps<T>& bitmap) { return And(bitmap); } - Y_FORCE_INLINE TThis& operator&=(const TChunk& val) { + Y_FORCE_INLINE TThis& operator&=(const TChunk& val) { return And(val); } template <class T> - Y_FORCE_INLINE TThis& operator|=(const TBitMapOps<T>& bitmap) { + Y_FORCE_INLINE TThis& operator|=(const TBitMapOps<T>& bitmap) { return Or(bitmap); } - Y_FORCE_INLINE TThis& operator|=(const TChunk& val) { + Y_FORCE_INLINE TThis& operator|=(const TChunk& val) { return Or(val); } template <class T> - Y_FORCE_INLINE TThis& operator^=(const TBitMapOps<T>& bitmap) { + Y_FORCE_INLINE TThis& operator^=(const TBitMapOps<T>& bitmap) { return Xor(bitmap); } - Y_FORCE_INLINE TThis& operator^=(const TChunk& val) { + Y_FORCE_INLINE TThis& operator^=(const TChunk& val) { return Xor(val); } template <class T> - Y_FORCE_INLINE TThis& operator-=(const TBitMapOps<T>& bitmap) { + Y_FORCE_INLINE TThis& operator-=(const TBitMapOps<T>& bitmap) { return SetDifference(bitmap); } - Y_FORCE_INLINE TThis& operator-=(const TChunk& val) { + Y_FORCE_INLINE TThis& operator-=(const TChunk& val) { return SetDifference(val); } - Y_FORCE_INLINE TThis& operator<<=(size_t pos) { + Y_FORCE_INLINE TThis& operator<<=(size_t pos) { return LShift(pos); } - Y_FORCE_INLINE TThis& operator>>=(size_t pos) { + Y_FORCE_INLINE TThis& operator>>=(size_t pos) { return RShift(pos); } - Y_FORCE_INLINE TThis operator<<(size_t pos) const { + Y_FORCE_INLINE TThis operator<<(size_t pos) const { return TThis(*this).LShift(pos); } - Y_FORCE_INLINE TThis operator>>(size_t pos) const { + Y_FORCE_INLINE TThis operator>>(size_t pos) const { return TThis(*this).RShift(pos); } - Y_FORCE_INLINE bool operator[](size_t pos) const { + Y_FORCE_INLINE bool operator[](size_t pos) const { return Get(pos); } - Y_FORCE_INLINE TReference operator[](size_t pos) { + Y_FORCE_INLINE TReference operator[](size_t pos) { const bool fitStorage = Mask.ExpandBitSize(pos + 1); Y_ASSERT(fitStorage); return TReference(&Mask.Data[pos >> DivCount], ModMask & pos); } - Y_FORCE_INLINE void Swap(TThis& bitmap) { + Y_FORCE_INLINE void Swap(TThis& bitmap) { DoSwap(Mask, bitmap.Mask); } - Y_FORCE_INLINE TThis& Set(size_t pos) { + Y_FORCE_INLINE TThis& Set(size_t pos) { const bool fitStorage = Mask.ExpandBitSize(pos + 1); Y_ASSERT(fitStorage); Mask.Data[pos >> DivCount] |= static_cast<TChunk>(1) << (pos & ModMask); @@ -535,7 +535,7 @@ public: return *this; } - Y_FORCE_INLINE TThis& Reset(size_t pos) { + Y_FORCE_INLINE TThis& Reset(size_t pos) { if ((pos >> DivCount) < Mask.GetChunkCapacity()) { Mask.Data[pos >> DivCount] &= ~(static_cast<TChunk>(1) << (pos & ModMask)); } @@ -551,14 +551,14 @@ public: return *this; } - Y_FORCE_INLINE TThis& Flip(size_t pos) { + Y_FORCE_INLINE TThis& Flip(size_t pos) { const bool fitStorage = Mask.ExpandBitSize(pos + 1); Y_ASSERT(fitStorage); Mask.Data[pos >> DivCount] ^= static_cast<TChunk>(1) << (pos & ModMask); return *this; } - Y_FORCE_INLINE bool Get(size_t pos) const { + Y_FORCE_INLINE bool Get(size_t pos) const { if ((pos >> DivCount) < Mask.GetChunkCapacity()) { return Mask.Data[pos >> DivCount] & (static_cast<TChunk>(1) << (pos & ModMask)); } @@ -588,22 +588,22 @@ public: } } - Y_FORCE_INLINE bool Test(size_t n) const { + Y_FORCE_INLINE bool Test(size_t n) const { return Get(n); } - Y_FORCE_INLINE TThis& Push(bool val) { + Y_FORCE_INLINE TThis& Push(bool val) { LShift(1); return val ? Set(0) : *this; } - Y_FORCE_INLINE bool Pop() { + Y_FORCE_INLINE bool Pop() { bool val = Get(0); return RShift(1), val; } // Clear entire bitmap. Current capacity is kept unchanged - Y_FORCE_INLINE TThis& Clear() { + Y_FORCE_INLINE TThis& Clear() { for (size_t i = 0; i < Mask.GetChunkCapacity(); ++i) { Mask.Data[i] = 0; } @@ -615,11 +615,11 @@ public: return Mask.GetBitCapacity(); } - Y_FORCE_INLINE void Reserve(size_t bitCount) { + Y_FORCE_INLINE void Reserve(size_t bitCount) { Y_VERIFY(Mask.ExpandBitSize(bitCount), "Exceeding bitmap storage capacity"); } - Y_FORCE_INLINE size_t ValueBitCount() const { + Y_FORCE_INLINE size_t ValueBitCount() const { size_t nonZeroChunk = Mask.GetChunkCapacity() - 1; while (nonZeroChunk != 0 && !Mask.Data[nonZeroChunk]) --nonZeroChunk; @@ -645,11 +645,11 @@ public: } template <class T> - Y_FORCE_INLINE bool HasAny(const TBitMapOps<T>& bitmap) const { + Y_FORCE_INLINE bool HasAny(const TBitMapOps<T>& bitmap) const { return HasAny(TThis(bitmap)); } - Y_FORCE_INLINE bool HasAny(const TChunk& val) const { + Y_FORCE_INLINE bool HasAny(const TChunk& val) const { return 0 != (Mask.Data[0] & val); } @@ -668,11 +668,11 @@ public: } template <class T> - Y_FORCE_INLINE bool HasAll(const TBitMapOps<T>& bitmap) const { + Y_FORCE_INLINE bool HasAll(const TBitMapOps<T>& bitmap) const { return HasAll(TThis(bitmap)); } - Y_FORCE_INLINE bool HasAll(const TChunk& val) const { + Y_FORCE_INLINE bool HasAll(const TChunk& val) const { return (Mask.Data[0] & val) == val; } @@ -688,11 +688,11 @@ public: } template <class T> - Y_FORCE_INLINE TThis& And(const TBitMapOps<T>& bitmap) { + Y_FORCE_INLINE TThis& And(const TBitMapOps<T>& bitmap) { return And(TThis(bitmap)); } - Y_FORCE_INLINE TThis& And(const TChunk& val) { + Y_FORCE_INLINE TThis& And(const TChunk& val) { Mask.Data[0] &= val; for (size_t i = 1; i < Mask.GetChunkCapacity(); ++i) Mask.Data[i] = 0; @@ -711,11 +711,11 @@ public: } template <class T> - Y_FORCE_INLINE TThis& Or(const TBitMapOps<T>& bitmap) { + Y_FORCE_INLINE TThis& Or(const TBitMapOps<T>& bitmap) { return Or(TThis(bitmap)); } - Y_FORCE_INLINE TThis& Or(const TChunk& val) { + Y_FORCE_INLINE TThis& Or(const TChunk& val) { Mask.Data[0] |= val; Mask.Sanitize(); return *this; @@ -729,11 +729,11 @@ public: } template <class T> - Y_FORCE_INLINE TThis& Xor(const TBitMapOps<T>& bitmap) { + Y_FORCE_INLINE TThis& Xor(const TBitMapOps<T>& bitmap) { return Xor(TThis(bitmap)); } - Y_FORCE_INLINE TThis& Xor(const TChunk& val) { + Y_FORCE_INLINE TThis& Xor(const TChunk& val) { Mask.Data[0] ^= val; Mask.Sanitize(); return *this; @@ -746,16 +746,16 @@ public: } template <class T> - Y_FORCE_INLINE TThis& SetDifference(const TBitMapOps<T>& bitmap) { + Y_FORCE_INLINE TThis& SetDifference(const TBitMapOps<T>& bitmap) { return SetDifference(TThis(bitmap)); } - Y_FORCE_INLINE TThis& SetDifference(const TChunk& val) { + Y_FORCE_INLINE TThis& SetDifference(const TChunk& val) { Mask.Data[0] &= ~val; return *this; } - Y_FORCE_INLINE TThis& Flip() { + Y_FORCE_INLINE TThis& Flip() { for (size_t i = 0; i < Mask.GetChunkCapacity(); ++i) Mask.Data[i] = ~Mask.Data[i]; Mask.Sanitize(); @@ -877,7 +877,7 @@ public: } template <class T> - Y_FORCE_INLINE bool Equal(const TBitMapOps<T>& bitmap) const { + Y_FORCE_INLINE bool Equal(const TBitMapOps<T>& bitmap) const { return Equal(TThis(bitmap)); } @@ -902,12 +902,12 @@ public: } template <class T> - Y_FORCE_INLINE int Compare(const TBitMapOps<T>& bitmap) const { + Y_FORCE_INLINE int Compare(const TBitMapOps<T>& bitmap) const { return Compare(TThis(bitmap)); } // For backward compatibility - Y_FORCE_INLINE static int Compare(const TThis& l, const TThis& r) { + Y_FORCE_INLINE static int Compare(const TThis& l, const TThis& r) { return l.Compare(r); } @@ -951,7 +951,7 @@ public: return Size(); } - Y_FORCE_INLINE size_t Count() const { + Y_FORCE_INLINE size_t Count() const { size_t count = 0; for (size_t i = 0; i < Mask.GetChunkCapacity(); ++i) count += ::NBitMapPrivate::CountBitsPrivate(Mask.Data[i]); diff --git a/util/generic/bitops.h b/util/generic/bitops.h index 2db15fc59b..518eb720b5 100644 --- a/util/generic/bitops.h +++ b/util/generic/bitops.h @@ -33,27 +33,27 @@ namespace NBitOps { // see http://www-graphics.stanford.edu/~seander/bithacks.html#ReverseParallel - Y_FORCE_INLINE ui64 SwapOddEvenBits(ui64 v) { + Y_FORCE_INLINE ui64 SwapOddEvenBits(ui64 v) { return ((v >> 1ULL) & 0x5555555555555555ULL) | ((v & 0x5555555555555555ULL) << 1ULL); } - Y_FORCE_INLINE ui64 SwapBitPairs(ui64 v) { + Y_FORCE_INLINE ui64 SwapBitPairs(ui64 v) { return ((v >> 2ULL) & 0x3333333333333333ULL) | ((v & 0x3333333333333333ULL) << 2ULL); } - Y_FORCE_INLINE ui64 SwapNibbles(ui64 v) { + Y_FORCE_INLINE ui64 SwapNibbles(ui64 v) { return ((v >> 4ULL) & 0x0F0F0F0F0F0F0F0FULL) | ((v & 0x0F0F0F0F0F0F0F0FULL) << 4ULL); } - Y_FORCE_INLINE ui64 SwapOddEvenBytes(ui64 v) { + Y_FORCE_INLINE ui64 SwapOddEvenBytes(ui64 v) { return ((v >> 8ULL) & 0x00FF00FF00FF00FFULL) | ((v & 0x00FF00FF00FF00FFULL) << 8ULL); } - Y_FORCE_INLINE ui64 SwapBytePairs(ui64 v) { + Y_FORCE_INLINE ui64 SwapBytePairs(ui64 v) { return ((v >> 16ULL) & 0x0000FFFF0000FFFFULL) | ((v & 0x0000FFFF0000FFFFULL) << 16ULL); } - Y_FORCE_INLINE ui64 SwapByteQuads(ui64 v) { + Y_FORCE_INLINE ui64 SwapByteQuads(ui64 v) { return (v >> 32ULL) | (v << 32ULL); } @@ -243,35 +243,35 @@ static inline unsigned CountTrailingZeroBits(T value) noexcept { /* * Returns 64-bit mask with `bits` lower bits set. */ -Y_FORCE_INLINE ui64 MaskLowerBits(ui64 bits) { +Y_FORCE_INLINE ui64 MaskLowerBits(ui64 bits) { return ::NBitOps::NPrivate::WORD_MASK[bits]; } /* * Return 64-bit mask with `bits` set starting from `skipbits`. */ -Y_FORCE_INLINE ui64 MaskLowerBits(ui64 bits, ui64 skipbits) { +Y_FORCE_INLINE ui64 MaskLowerBits(ui64 bits, ui64 skipbits) { return MaskLowerBits(bits) << skipbits; } /* * Return 64-bit mask with all bits set except for `bits` lower bits. */ -Y_FORCE_INLINE ui64 InverseMaskLowerBits(ui64 bits) { +Y_FORCE_INLINE ui64 InverseMaskLowerBits(ui64 bits) { return ::NBitOps::NPrivate::INVERSE_WORD_MASK[bits]; } /* * Return 64-bit mask with all bits set except for `bits` bitst starting from `skipbits`. */ -Y_FORCE_INLINE ui64 InverseMaskLowerBits(ui64 bits, ui64 skipbits) { +Y_FORCE_INLINE ui64 InverseMaskLowerBits(ui64 bits, ui64 skipbits) { return ~MaskLowerBits(bits, skipbits); } /* * Returns 0-based position of the most significant bit that is set. 0 for 0. */ -Y_FORCE_INLINE ui64 MostSignificantBit(ui64 v) { +Y_FORCE_INLINE ui64 MostSignificantBit(ui64 v) { #ifdef __GNUC__ ui64 res = v ? (63 - __builtin_clzll(v)) : 0; #elif defined(_MSC_VER) && defined(_64_) @@ -320,41 +320,41 @@ constexpr ui64 MostSignificantBitCT(ui64 x) { /* * Return rounded up binary logarithm of `x`. */ -Y_FORCE_INLINE ui8 CeilLog2(ui64 x) { +Y_FORCE_INLINE ui8 CeilLog2(ui64 x) { return static_cast<ui8>(MostSignificantBit(x - 1)) + 1; } -Y_FORCE_INLINE ui8 ReverseBytes(ui8 t) { +Y_FORCE_INLINE ui8 ReverseBytes(ui8 t) { return t; } -Y_FORCE_INLINE ui16 ReverseBytes(ui16 t) { +Y_FORCE_INLINE ui16 ReverseBytes(ui16 t) { return static_cast<ui16>(::NBitOps::NPrivate::SwapOddEvenBytes(t)); } -Y_FORCE_INLINE ui32 ReverseBytes(ui32 t) { +Y_FORCE_INLINE ui32 ReverseBytes(ui32 t) { return static_cast<ui32>(::NBitOps::NPrivate::SwapBytePairs( ::NBitOps::NPrivate::SwapOddEvenBytes(t))); } -Y_FORCE_INLINE ui64 ReverseBytes(ui64 t) { +Y_FORCE_INLINE ui64 ReverseBytes(ui64 t) { return ::NBitOps::NPrivate::SwapByteQuads((::NBitOps::NPrivate::SwapOddEvenBytes(t))); } -Y_FORCE_INLINE ui8 ReverseBits(ui8 t) { +Y_FORCE_INLINE ui8 ReverseBits(ui8 t) { return static_cast<ui8>(::NBitOps::NPrivate::SwapNibbles( ::NBitOps::NPrivate::SwapBitPairs( ::NBitOps::NPrivate::SwapOddEvenBits(t)))); } -Y_FORCE_INLINE ui16 ReverseBits(ui16 t) { +Y_FORCE_INLINE ui16 ReverseBits(ui16 t) { return static_cast<ui16>(::NBitOps::NPrivate::SwapOddEvenBytes( ::NBitOps::NPrivate::SwapNibbles( ::NBitOps::NPrivate::SwapBitPairs( ::NBitOps::NPrivate::SwapOddEvenBits(t))))); } -Y_FORCE_INLINE ui32 ReverseBits(ui32 t) { +Y_FORCE_INLINE ui32 ReverseBits(ui32 t) { return static_cast<ui32>(::NBitOps::NPrivate::SwapBytePairs( ::NBitOps::NPrivate::SwapOddEvenBytes( ::NBitOps::NPrivate::SwapNibbles( @@ -362,7 +362,7 @@ Y_FORCE_INLINE ui32 ReverseBits(ui32 t) { ::NBitOps::NPrivate::SwapOddEvenBits(t)))))); } -Y_FORCE_INLINE ui64 ReverseBits(ui64 t) { +Y_FORCE_INLINE ui64 ReverseBits(ui64 t) { return ::NBitOps::NPrivate::SwapByteQuads( ::NBitOps::NPrivate::SwapBytePairs( ::NBitOps::NPrivate::SwapOddEvenBytes( @@ -376,7 +376,7 @@ Y_FORCE_INLINE ui64 ReverseBits(ui64 t) { * 1000111000111000 , bits = 6 => 1000111000000111 */ template <typename T> -Y_FORCE_INLINE T ReverseBits(T v, ui64 bits) { +Y_FORCE_INLINE T ReverseBits(T v, ui64 bits) { return bits ? (T(v & ::InverseMaskLowerBits(bits)) | T(ReverseBits(T(v & ::MaskLowerBits(bits)))) >> ((ui64{sizeof(T)} << ui64{3}) - bits)) : v; } @@ -385,7 +385,7 @@ Y_FORCE_INLINE T ReverseBits(T v, ui64 bits) { * 1000111000111000 , bits = 4, skipbits = 2 => 1000111000011100 */ template <typename T> -Y_FORCE_INLINE T ReverseBits(T v, ui64 bits, ui64 skipbits) { +Y_FORCE_INLINE T ReverseBits(T v, ui64 bits, ui64 skipbits) { return (T(ReverseBits((v >> skipbits), bits)) << skipbits) | T(v & MaskLowerBits(skipbits)); } diff --git a/util/generic/flags.h b/util/generic/flags.h index a1f5921d42..0591c63402 100644 --- a/util/generic/flags.h +++ b/util/generic/flags.h @@ -55,10 +55,10 @@ public: return Value_; } - constexpr TInt ToBaseType() const { - return Value_; - } - + constexpr TInt ToBaseType() const { + return Value_; + } + constexpr static TFlags FromBaseType(TInt value) { return TFlags(TFlag(value)); } diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp index 0551d58770..2bdc87658b 100644 --- a/util/generic/hash_ut.cpp +++ b/util/generic/hash_ut.cpp @@ -7,7 +7,7 @@ #include <utility> #include <util/str_stl.h> -#include <util/digest/multi.h> +#include <util/digest/multi.h> static const char star = 42; @@ -58,7 +58,7 @@ class THashTest: public TTestBase { UNIT_TEST(TestHSetInitializerList); UNIT_TEST(TestHMSetInitializerList); UNIT_TEST(TestHSetInsertInitializerList); - UNIT_TEST(TestTupleHash); + UNIT_TEST(TestTupleHash); UNIT_TEST_SUITE_END(); using hmset = THashMultiSet<char, hash<char>, TEqualTo<char>>; @@ -109,7 +109,7 @@ protected: void TestHSetInitializerList(); void TestHMSetInitializerList(); void TestHSetInsertInitializerList(); - void TestTupleHash(); + void TestTupleHash(); }; UNIT_TEST_SUITE_REGISTRATION(THashTest); @@ -1249,23 +1249,23 @@ void THashTest::TestHSetInsertInitializerList() { UNIT_ASSERT_VALUES_EQUAL(x, y); } } - -/* -* Sequence for MultiHash is reversed as it calculates hash as -* f(head:tail) = f(tail)xHash(head) -*/ -void THashTest::TestTupleHash() { - std::tuple<int, int> tuple{1, 3}; - UNIT_ASSERT_VALUES_EQUAL(THash<decltype(tuple)>()(tuple), MultiHash(3, 1)); - - /* - * This thing checks that we didn't break STL code - * See https://a.yandex-team.ru/arc/commit/2864838#comment-401 - * for example - */ - struct A { + +/* +* Sequence for MultiHash is reversed as it calculates hash as +* f(head:tail) = f(tail)xHash(head) +*/ +void THashTest::TestTupleHash() { + std::tuple<int, int> tuple{1, 3}; + UNIT_ASSERT_VALUES_EQUAL(THash<decltype(tuple)>()(tuple), MultiHash(3, 1)); + + /* + * This thing checks that we didn't break STL code + * See https://a.yandex-team.ru/arc/commit/2864838#comment-401 + * for example + */ + struct A { A Foo(const std::tuple<A, float>& v) { - return std::get<A>(v); - } - }; -} + return std::get<A>(v); + } + }; +} diff --git a/util/generic/string.h b/util/generic/string.h index 8cd8aa6917..1179811618 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -930,11 +930,11 @@ public: } friend TBasicString operator+(const TBasicStringBuf<TCharType, TTraits> s1, const TBasicString& s2) Y_WARN_UNUSED_RESULT { - return Join(s1, s2); + return Join(s1, s2); } friend TBasicString operator+(const TCharType* s1, const TBasicString& s2) Y_WARN_UNUSED_RESULT { - return Join(s1, s2); + return Join(s1, s2); } friend TBasicString operator+(std::basic_string<TCharType, TTraits> l, TBasicString r) { diff --git a/util/str_stl.h b/util/str_stl.h index f1e137181d..994ce78cea 100644 --- a/util/str_stl.h +++ b/util/str_stl.h @@ -111,36 +111,36 @@ struct THash<std::type_index> { } }; -namespace NHashPrivate { - template <typename T> - Y_FORCE_INLINE static size_t HashObject(const T& val) { - return THash<T>()(val); - } - - template <size_t I, bool IsLastElement, typename... TArgs> - struct TupleHashHelper { - Y_FORCE_INLINE static size_t Hash(const std::tuple<TArgs...>& tuple) { - return CombineHashes(HashObject(std::get<I>(tuple)), +namespace NHashPrivate { + template <typename T> + Y_FORCE_INLINE static size_t HashObject(const T& val) { + return THash<T>()(val); + } + + template <size_t I, bool IsLastElement, typename... TArgs> + struct TupleHashHelper { + Y_FORCE_INLINE static size_t Hash(const std::tuple<TArgs...>& tuple) { + return CombineHashes(HashObject(std::get<I>(tuple)), TupleHashHelper<I + 1, I + 2 >= sizeof...(TArgs), TArgs...>::Hash(tuple)); - } - }; - - template <size_t I, typename... TArgs> - struct TupleHashHelper<I, true, TArgs...> { - Y_FORCE_INLINE static size_t Hash(const std::tuple<TArgs...>& tuple) { - return HashObject(std::get<I>(tuple)); - } - }; - + } + }; + + template <size_t I, typename... TArgs> + struct TupleHashHelper<I, true, TArgs...> { + Y_FORCE_INLINE static size_t Hash(const std::tuple<TArgs...>& tuple) { + return HashObject(std::get<I>(tuple)); + } + }; + } - -template <typename... TArgs> -struct THash<std::tuple<TArgs...>> { - size_t operator()(const std::tuple<TArgs...>& tuple) const { - return NHashPrivate::TupleHashHelper<0, 1 >= sizeof...(TArgs), TArgs...>::Hash(tuple); - } -}; - + +template <typename... TArgs> +struct THash<std::tuple<TArgs...>> { + size_t operator()(const std::tuple<TArgs...>& tuple) const { + return NHashPrivate::TupleHashHelper<0, 1 >= sizeof...(TArgs), TArgs...>::Hash(tuple); + } +}; + template <class T> struct THash: public ::hash<T> { }; diff --git a/util/system/compiler.h b/util/system/compiler.h index b373edcc46..02700b1659 100644 --- a/util/system/compiler.h +++ b/util/system/compiler.h @@ -84,12 +84,12 @@ #endif /** - * @def Y_FORCE_INLINE + * @def Y_FORCE_INLINE * * Macro to use in place of 'inline' in function declaration/definition to force * it to be inlined. */ -#if !defined(Y_FORCE_INLINE) +#if !defined(Y_FORCE_INLINE) #if defined(CLANG_COVERAGE) #/* excessive __always_inline__ might significantly slow down compilation of an instrumented unit */ #define Y_FORCE_INLINE inline diff --git a/util/system/defaults.h b/util/system/defaults.h index dcd7abea38..5a800c288f 100644 --- a/util/system/defaults.h +++ b/util/system/defaults.h @@ -141,7 +141,7 @@ constexpr bool Y_IS_DEBUG_BUILD = true; #define Y_CAT_I(X, Y) Y_CAT_II(X, Y) #define Y_CAT_II(X, Y) X##Y -#define Y_STRINGIZE(X) UTIL_PRIVATE_STRINGIZE_AUX(X) +#define Y_STRINGIZE(X) UTIL_PRIVATE_STRINGIZE_AUX(X) #define UTIL_PRIVATE_STRINGIZE_AUX(X) #X #if defined(__COUNTER__) diff --git a/util/system/file.cpp b/util/system/file.cpp index 4a261d020c..018878bb17 100644 --- a/util/system/file.cpp +++ b/util/system/file.cpp @@ -65,7 +65,7 @@ static bool IsStupidFlagCombination(EOpenMode oMode) { TFileHandle::TFileHandle(const TString& fName, EOpenMode oMode) noexcept { ui32 fcMode = 0; - EOpenMode createMode = oMode & MaskCreation; + EOpenMode createMode = oMode & MaskCreation; Y_VERIFY(!IsStupidFlagCombination(oMode), "oMode %d makes no sense", static_cast<int>(oMode)); if (!(oMode & MaskRW)) { oMode |= RdWr; @@ -854,7 +854,7 @@ public: , FileName_(fName) { if (!Handle_.IsOpen()) { - ythrow TFileError() << "can't open " << fName.Quote() << " with mode " << DecodeOpenMode(oMode) << " (" << Hex(oMode.ToBaseType()) << ")"; + ythrow TFileError() << "can't open " << fName.Quote() << " with mode " << DecodeOpenMode(oMode) << " (" << Hex(oMode.ToBaseType()) << ")"; } } diff --git a/util/system/file.h b/util/system/file.h index 9502e159b6..268051cd8a 100644 --- a/util/system/file.h +++ b/util/system/file.h @@ -3,13 +3,13 @@ #include "fhandle.h" #include "flock.h" -#include <util/generic/flags.h> +#include <util/generic/flags.h> #include <util/generic/ptr.h> #include <util/generic/noncopyable.h> #include <cstdio> -enum EOpenModeFlag { +enum EOpenModeFlag { OpenExisting = 0, // Opens a file. It fails if the file does not exist. TruncExisting = 1, // Opens a file and truncates it to zero size. It fails if the file does not exist. OpenAlways = 2, // Opens a file, always. If a file does not exist, it creates a file. @@ -49,9 +49,9 @@ enum EOpenModeFlag { AMask = 0x0FFF0000, }; -Y_DECLARE_FLAGS(EOpenMode, EOpenModeFlag) -Y_DECLARE_OPERATORS_FOR_FLAGS(EOpenMode) - +Y_DECLARE_FLAGS(EOpenMode, EOpenModeFlag) +Y_DECLARE_OPERATORS_FOR_FLAGS(EOpenMode) + TString DecodeOpenMode(ui32 openMode); enum SeekDir { |