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 | f860932520ce9bc8540a3c19e84c0109c3437dc5 (patch) | |
tree | c0748b5dcbade83af788c0abfa89c0383d6b779c | |
parent | e2021f9a0e54d13b7c48796318b13b66dc625e74 (diff) | |
download | ydb-f860932520ce9bc8540a3c19e84c0109c3437dc5.tar.gz |
Restoring authorship annotation for <breakneck@yandex-team.ru>. Commit 2 of 2.
43 files changed, 465 insertions, 465 deletions
diff --git a/build/ya.conf.json b/build/ya.conf.json index 1939e31aee..5f7cc875d6 100644 --- a/build/ya.conf.json +++ b/build/ya.conf.json @@ -2753,14 +2753,14 @@ ] } }, - "gdbserver": { - "tools": { + "gdbserver": { + "tools": { "gdbserver": { "bottle": "gdb", "executable": "gdbserver" } - }, - "platforms": [ + }, + "platforms": [ { "host": { "os": "LINUX" @@ -2786,8 +2786,8 @@ }, "default": true } - ] - }, + ] + }, "python": { "tools": { "python": { @@ -3753,13 +3753,13 @@ } ] }, - "rsync": { - "tools": { + "rsync": { + "tools": { "rsync": { "bottle": "rsync", "executable": "rsync" } - }, + }, "platforms": [ { "host": { @@ -3768,7 +3768,7 @@ "default": true } ] - }, + }, "kiwi": { "tools": { "kwmktorrent": { @@ -6949,20 +6949,20 @@ ] } }, - "rsync": { - "formula": { + "rsync": { + "formula": { "sandbox_id": [ 65088954 ], - "match": "rsync" - }, - "executable": { + "match": "rsync" + }, + "executable": { "rsync": [ "bin", "rsync" ] - } - }, + } + }, "svn110": { "formula": { "sandbox_id": 368201676, @@ -6996,7 +6996,7 @@ }, "cmake": { "formula": { - "sandbox_id": 105454515, + "sandbox_id": 105454515, "match": "cmake" }, "executable": { diff --git a/contrib/libs/cxxsupp/libcxx/include/stlfwd b/contrib/libs/cxxsupp/libcxx/include/stlfwd index bce761c4de..adad6790dc 100644 --- a/contrib/libs/cxxsupp/libcxx/include/stlfwd +++ b/contrib/libs/cxxsupp/libcxx/include/stlfwd @@ -37,11 +37,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class K, class V, class C, class A> class multimap; - template <typename... TArgs> - class tuple; - - constexpr void get(...) = delete; - + template <typename... TArgs> + class tuple; + + constexpr void get(...) = delete; + template <class> class _LIBCPP_TEMPLATE_VIS function; diff --git a/contrib/libs/openssl/openssl.package.json b/contrib/libs/openssl/openssl.package.json index bed93dd753..e98964e506 100644 --- a/contrib/libs/openssl/openssl.package.json +++ b/contrib/libs/openssl/openssl.package.json @@ -1,37 +1,37 @@ -{ - "meta": { - "name": "libyandex-openssl-dev", - "version": "1.0.2j-r{revision}", - "maintainer": "Sergey Mironov <kohen@yandex-team.ru>", - "description": "Statically linked OpenSSL from arcadia, headers\nWith Yandex' patches\nApproved by security" - }, - "build": { - "targets": [ - "contrib/libs/openssl" - ] - }, - "data": [ - { - "source": { - "type": "BUILD_OUTPUT", - "path": "contrib/libs/openssl", - "files": [ - "libcontrib-libs-openssl.a" - ] - }, - "destination": { - "path": "/usr/lib/" - } - }, - { - "source": { - "path": "contrib/libs/openssl/include/openssl", - "scheme": "svn", - "type": "ARCADIA" - }, - "destination": { - "path": "/usr/include/yandex-newssl/" - } - } - ] -} +{ + "meta": { + "name": "libyandex-openssl-dev", + "version": "1.0.2j-r{revision}", + "maintainer": "Sergey Mironov <kohen@yandex-team.ru>", + "description": "Statically linked OpenSSL from arcadia, headers\nWith Yandex' patches\nApproved by security" + }, + "build": { + "targets": [ + "contrib/libs/openssl" + ] + }, + "data": [ + { + "source": { + "type": "BUILD_OUTPUT", + "path": "contrib/libs/openssl", + "files": [ + "libcontrib-libs-openssl.a" + ] + }, + "destination": { + "path": "/usr/lib/" + } + }, + { + "source": { + "path": "contrib/libs/openssl/include/openssl", + "scheme": "svn", + "type": "ARCADIA" + }, + "destination": { + "path": "/usr/include/yandex-newssl/" + } + } + ] +} diff --git a/contrib/python/ya.make b/contrib/python/ya.make index a5a6ce4ad0..d01ced9f3a 100644 --- a/contrib/python/ya.make +++ b/contrib/python/ya.make @@ -1093,7 +1093,7 @@ RECURSE( txaio txredisapi typecode - typed-argument-parser + typed-argument-parser typed-ast typeguard typer diff --git a/library/cpp/bit_io/bitinput.h b/library/cpp/bit_io/bitinput.h index 288f04c96f..85711eb7f9 100644 --- a/library/cpp/bit_io/bitinput.h +++ b/library/cpp/bit_io/bitinput.h @@ -43,7 +43,7 @@ namespace NBitIO { // Read with static number of bits. // Preserves what's in result. template <ui64 bits, typename T> - Y_FORCE_INLINE bool ReadK(T& result, ui64 skipbits) { + Y_FORCE_INLINE bool ReadK(T& result, ui64 skipbits) { ui64 r64 = 0; bool ret = bits <= 56 ? ReadKImpl<bits>(r64) : ReadSafe(r64, bits); CopyToResultK<bits>(result, r64, skipbits); @@ -53,7 +53,7 @@ namespace NBitIO { // Read with static number of bits. // Zeroes other bits in result. template <ui64 bits, typename T> - Y_FORCE_INLINE bool ReadK(T& result) { + Y_FORCE_INLINE bool ReadK(T& result) { ui64 r = 0; bool res = ReadK<bits>(r); result = r; @@ -62,7 +62,7 @@ namespace NBitIO { // Shortcut to impl. template <ui64 bits> - Y_FORCE_INLINE bool ReadK(ui64& result) { + Y_FORCE_INLINE bool ReadK(ui64& result) { if (bits <= 56) return ReadKImpl<bits>(result); @@ -80,7 +80,7 @@ namespace NBitIO { // It's safe to read up to 64 bits. // Zeroes other bits in result. template <typename T> - Y_FORCE_INLINE bool ReadSafe(T& result, ui64 bits) { + Y_FORCE_INLINE bool ReadSafe(T& result, ui64 bits) { if (bits <= 56ULL) return Read(result, bits); @@ -98,7 +98,7 @@ namespace NBitIO { // It's safe to read up to 64 bits. // Preserves what's in result. template <typename T> - Y_FORCE_INLINE bool ReadSafe(T& result, ui64 bits, ui64 skipbits) { + Y_FORCE_INLINE bool ReadSafe(T& result, ui64 bits, ui64 skipbits) { ui64 r64 = 0; bool ret = ReadSafe(r64, bits); CopyToResult(result, r64, bits, skipbits); @@ -108,7 +108,7 @@ namespace NBitIO { // Do not try to read more than 56 bits at once. Split in two reads or use ReadSafe. // Zeroes other bits in result. template <typename T> - Y_FORCE_INLINE bool Read(T& result, ui64 bits) { + Y_FORCE_INLINE bool Read(T& result, ui64 bits) { ui64 r64 = 0; bool ret = ReadImpl(r64, bits); result = r64; @@ -116,14 +116,14 @@ namespace NBitIO { } // Shortcut to impl. - Y_FORCE_INLINE bool Read(ui64& result, ui64 bits) { + Y_FORCE_INLINE bool Read(ui64& result, ui64 bits) { return ReadImpl(result, bits); } // Do not try to read more than 56 bits at once. Split in two reads or use ReadSafe. // Preserves what's in result. template <typename T> - Y_FORCE_INLINE bool Read(T& result, ui64 bits, ui64 skipbits) { + Y_FORCE_INLINE bool Read(T& result, ui64 bits, ui64 skipbits) { ui64 r64 = 0; bool ret = ReadImpl(r64, bits); CopyToResult(result, r64, bits, skipbits); @@ -134,7 +134,7 @@ namespace NBitIO { // Like this: (unsigned char)0x2E<3> (0010 1110) <=> 1110 0101 // fddd fddd template <ui64 bits, typename T> - Y_FORCE_INLINE bool ReadWords(T& result) { + Y_FORCE_INLINE bool ReadWords(T& result) { ui64 r64 = 0; bool retCode = ReadWordsImpl<bits>(r64); @@ -145,22 +145,22 @@ namespace NBitIO { // Shortcut to impl. template <ui64 bits> - Y_FORCE_INLINE bool ReadWords(ui64& result) { + Y_FORCE_INLINE bool ReadWords(ui64& result) { return ReadWordsImpl<bits>(result); } - Y_FORCE_INLINE bool Back(int bits) { + Y_FORCE_INLINE bool Back(int bits) { return Seek(BitOffset() - bits); } - Y_FORCE_INLINE bool Seek(int bitoffset) { + Y_FORCE_INLINE bool Seek(int bitoffset) { return TBitInputImpl::Seek(bitoffset); } // A way to read a portion of bits at random location. // Didn't want to complicate sequential read, neither to copypaste. template <typename T> - Y_FORCE_INLINE bool ReadRandom(ui64 bitoffset, T& result, ui64 bits, ui64 skipbits) { + Y_FORCE_INLINE bool ReadRandom(ui64 bitoffset, T& result, ui64 bits, ui64 skipbits) { const ui64 curr = BitOffset(); Seek(bitoffset); bool ret = ReadSafe<T>(result, bits, skipbits); diff --git a/library/cpp/bit_io/bitinput_impl.h b/library/cpp/bit_io/bitinput_impl.h index 0a5320790c..b13fbef101 100644 --- a/library/cpp/bit_io/bitinput_impl.h +++ b/library/cpp/bit_io/bitinput_impl.h @@ -32,7 +32,7 @@ namespace NBitIO { protected: template <ui32 bits> - Y_FORCE_INLINE bool ReadKImpl(ui64& result) { + Y_FORCE_INLINE bool ReadKImpl(ui64& result) { result = (ReadUnaligned<ui64>((const void*)(Start + (BOffset >> 3))) >> (BOffset & 7)) & Mask64(bits); BOffset += bits; if (BOffset < FakeStart) @@ -46,7 +46,7 @@ namespace NBitIO { return true; } - Y_FORCE_INLINE bool ReadImpl(ui64& result, ui32 bits) { + Y_FORCE_INLINE bool ReadImpl(ui64& result, ui32 bits) { result = (ReadUnaligned<ui64>((const void*)(Start + (BOffset >> 3))) >> (BOffset & 7)) & MaskLowerBits(bits); BOffset += bits; if (BOffset < FakeStart) @@ -60,15 +60,15 @@ namespace NBitIO { return true; } - Y_FORCE_INLINE bool EofImpl() const { + Y_FORCE_INLINE bool EofImpl() const { return BOffset >= Length; } - Y_FORCE_INLINE ui64 BitOffset() const { + Y_FORCE_INLINE ui64 BitOffset() const { return BOffset; } - Y_FORCE_INLINE bool Seek(i64 offset) { + Y_FORCE_INLINE bool Seek(i64 offset) { if (offset < 0 || offset > (i64)Length) return false; BOffset = offset; @@ -78,18 +78,18 @@ namespace NBitIO { protected: template <ui64 bits, typename T> - Y_FORCE_INLINE static void CopyToResultK(T& result, ui64 r64, ui64 skipbits) { + Y_FORCE_INLINE static void CopyToResultK(T& result, ui64 r64, ui64 skipbits) { result = (result & ~(Mask64(bits) << skipbits)) | (r64 << skipbits); } template <typename T> - Y_FORCE_INLINE static void CopyToResult(T& result, ui64 r64, ui64 bits, ui64 skipbits) { + Y_FORCE_INLINE static void CopyToResult(T& result, ui64 r64, ui64 bits, ui64 skipbits) { result = (result & InverseMaskLowerBits(bits, skipbits)) | (r64 << skipbits); } public: template <ui64 bits> - Y_FORCE_INLINE bool ReadWordsImpl(ui64& data) { + Y_FORCE_INLINE bool ReadWordsImpl(ui64& data) { data = 0; const ui64 haveMore = NthBit64(bits); diff --git a/library/cpp/bit_io/bitoutput.h b/library/cpp/bit_io/bitoutput.h index edadc5da0c..2b886c1f02 100644 --- a/library/cpp/bit_io/bitoutput.h +++ b/library/cpp/bit_io/bitoutput.h @@ -51,7 +51,7 @@ namespace NBitIO { // interface // Write "bits" lower bits. - Y_FORCE_INLINE void Write(ui64 data, ui64 bits) { + Y_FORCE_INLINE void Write(ui64 data, ui64 bits) { if (FreeBits < bits) { if (FreeBits) { bits -= FreeBits; @@ -70,7 +70,7 @@ namespace NBitIO { } // Write "bits" lower bits starting from "skipbits" bit. - Y_FORCE_INLINE void Write(ui64 data, ui64 bits, ui64 skipbits) { + Y_FORCE_INLINE void Write(ui64 data, ui64 bits, ui64 skipbits) { Write(data >> skipbits, bits); } @@ -78,7 +78,7 @@ namespace NBitIO { // Like this: (unsigned char)0x2E<3> (0000 0010 1110) <=> 1110 0101 // fddd fddd template <ui64 bits> - Y_FORCE_INLINE void WriteWords(ui64 data) { + Y_FORCE_INLINE void WriteWords(ui64 data) { do { ui64 part = data; @@ -88,7 +88,7 @@ namespace NBitIO { } while (data); } - Y_FORCE_INLINE ui64 /* padded bits */ Flush() { + Y_FORCE_INLINE ui64 /* padded bits */ Flush() { const ui64 ubytes = 8ULL - (FreeBits >> 3ULL); if (ubytes) { diff --git a/library/cpp/containers/comptrie/comptrie_impl.h b/library/cpp/containers/comptrie/comptrie_impl.h index a2b1f8f124..f41c38311a 100644 --- a/library/cpp/containers/comptrie/comptrie_impl.h +++ b/library/cpp/containers/comptrie/comptrie_impl.h @@ -15,11 +15,11 @@ namespace NCompactTrie { const size_t MT_LEFTSHIFT = 3; const size_t MT_RIGHTSHIFT = 0; - Y_FORCE_INLINE size_t UnpackOffset(const char* p, size_t len); + Y_FORCE_INLINE size_t UnpackOffset(const char* p, size_t len); size_t MeasureOffset(size_t offset); size_t PackOffset(char* buffer, size_t offset); static inline ui64 ArcSaveOffset(size_t offset, IOutputStream& os); - Y_FORCE_INLINE char LeapByte(const char*& datapos, const char* dataend, char label); + Y_FORCE_INLINE char LeapByte(const char*& datapos, const char* dataend, char label); template <class T> inline static size_t ExtraBits() { @@ -103,7 +103,7 @@ namespace NCompactTrie { // Unpack the offset to the next node. The encoding scheme can store offsets // up to 7 bytes; whether they fit into size_t is another issue. - Y_FORCE_INLINE size_t UnpackOffset(const char* p, size_t len) { + Y_FORCE_INLINE size_t UnpackOffset(const char* p, size_t len) { size_t result = 0; while (len--) @@ -116,7 +116,7 @@ namespace NCompactTrie { // to the position immediately preceding the value for the link just traversed (if any); // returns flags associated with the link. If no arc with the required label is present, // zeroes the data pointer. - Y_FORCE_INLINE char LeapByte(const char*& datapos, const char* dataend, char label) { + Y_FORCE_INLINE char LeapByte(const char*& datapos, const char* dataend, char label) { while (datapos < dataend) { size_t offsetlength, offset; const char* startpos = datapos; @@ -183,7 +183,7 @@ namespace NCompactTrie { // otherwise sets it to nullptr. // Returns true if the symbol was succesfully found in the trie, false otherwise. template <typename TSymbol, class TPacker> - Y_FORCE_INLINE bool Advance(const char*& datapos, const char* const dataend, const char*& value, + Y_FORCE_INLINE bool Advance(const char*& datapos, const char* const dataend, const char*& value, TSymbol label, TPacker packer) { Y_ASSERT(datapos < dataend); char flags = MT_NEXT; diff --git a/library/cpp/containers/sorted_vector/sorted_vector.h b/library/cpp/containers/sorted_vector/sorted_vector.h index ef709bf782..123539af9e 100644 --- a/library/cpp/containers/sorted_vector/sorted_vector.h +++ b/library/cpp/containers/sorted_vector/sorted_vector.h @@ -106,7 +106,7 @@ namespace NSorted { } // STL-compatible synonym - Y_FORCE_INLINE iterator insert(const value_type& value) { + Y_FORCE_INLINE iterator insert(const value_type& value) { return this->Insert(value); } @@ -119,7 +119,7 @@ namespace NSorted { // STL-compatible synonym template <class TIter> - Y_FORCE_INLINE void insert(TIter first, TIter last) { + Y_FORCE_INLINE void insert(TIter first, TIter last) { this->Insert(first, last); } @@ -136,7 +136,7 @@ namespace NSorted { } // STL-compatible synonym - Y_FORCE_INLINE std::pair<iterator, bool> insert_unique(const value_type& value) { + Y_FORCE_INLINE std::pair<iterator, bool> insert_unique(const value_type& value) { return this->InsertUnique(value); } @@ -150,7 +150,7 @@ namespace NSorted { // STL-compatible synonym template <class TIter> - Y_FORCE_INLINE void insert_unique(TIter first, TIter last) { + Y_FORCE_INLINE void insert_unique(TIter first, TIter last) { this->InsertUnique(first, last); } @@ -166,25 +166,25 @@ namespace NSorted { } // STL-compatible synonym - Y_FORCE_INLINE iterator insert_or_replace(const value_type& value) { + Y_FORCE_INLINE iterator insert_or_replace(const value_type& value) { return this->InsertOrReplace(value); } - Y_FORCE_INLINE void Sort() { + Y_FORCE_INLINE void Sort() { ::Sort(TBase::begin(), TBase::end(), TKeyCompare()); } // STL-compatible synonym - Y_FORCE_INLINE void sort() { + Y_FORCE_INLINE void sort() { this->Sort(); } - Y_FORCE_INLINE void Sort(iterator from, iterator to) { + Y_FORCE_INLINE void Sort(iterator from, iterator to) { ::Sort(from, to, TKeyCompare()); } // STL-compatible synonym - Y_FORCE_INLINE void sort(iterator from, iterator to) { + Y_FORCE_INLINE void sort(iterator from, iterator to) { this->Sort(from, to); } @@ -193,7 +193,7 @@ namespace NSorted { } // STL-compatible synonym - Y_FORCE_INLINE void make_unique() { + Y_FORCE_INLINE void make_unique() { this->MakeUnique(); } @@ -310,7 +310,7 @@ namespace NSorted { } // STL-compatible synonym - Y_FORCE_INLINE void erase(const key_type& key) { + Y_FORCE_INLINE void erase(const key_type& key) { this->Erase(key); } @@ -455,24 +455,24 @@ namespace NSorted { // Inserts value with unique key. Returns <iterator, bool> pair, // where the first member is the pointer to the inserted/existing value, and the // second member indicates either the value is inserted or not. - Y_FORCE_INLINE std::pair<iterator, bool> Insert(const TValueType& value) { + Y_FORCE_INLINE std::pair<iterator, bool> Insert(const TValueType& value) { return TBase::InsertUnique(value); } // STL-compatible synonym - Y_FORCE_INLINE std::pair<iterator, bool> insert(const TValueType& value) { + Y_FORCE_INLINE std::pair<iterator, bool> insert(const TValueType& value) { return TBase::InsertUnique(value); } // Inserts value range with unique keys. template <class TIter> - Y_FORCE_INLINE void Insert(TIter first, TIter last) { + Y_FORCE_INLINE void Insert(TIter first, TIter last) { TBase::InsertUnique(first, last); } // STL-compatible synonym template <class TIter> - Y_FORCE_INLINE void insert(TIter first, TIter last) { + Y_FORCE_INLINE void insert(TIter first, TIter last) { TBase::InsertUnique(first, last); } }; diff --git a/library/cpp/deprecated/split/split_iterator.h b/library/cpp/deprecated/split/split_iterator.h index d9b8c63858..0eacc29228 100644 --- a/library/cpp/deprecated/split/split_iterator.h +++ b/library/cpp/deprecated/split/split_iterator.h @@ -63,7 +63,7 @@ private: public: explicit TSplitDelimiters(const char* s); - Y_FORCE_INLINE bool IsDelimiter(ui8 ch) const { + Y_FORCE_INLINE bool IsDelimiter(ui8 ch) const { return Delims[ch]; } }; @@ -80,11 +80,11 @@ public: TSplitBase(const char* str, size_t length); TSplitBase(const TString& s); - Y_FORCE_INLINE const char* GetString() const { + Y_FORCE_INLINE const char* GetString() const { return Str; } - Y_FORCE_INLINE size_t GetLength() const { + Y_FORCE_INLINE size_t GetLength() const { return Len; } diff --git a/library/cpp/deprecated/ya.make b/library/cpp/deprecated/ya.make index 0db584e196..6c753f68a9 100644 --- a/library/cpp/deprecated/ya.make +++ b/library/cpp/deprecated/ya.make @@ -1,17 +1,17 @@ RECURSE( - abstract_iterator - abstract_iterator/ut + abstract_iterator + abstract_iterator/ut accessors accessors/ut autoarray base64 datafile - dater_old - dater_old/ut + dater_old + dater_old/ut enum_codegen enum_codegen/ut - fgood - fgood/ut + fgood + fgood/ut histogram ipreg1 ipreg1/ut @@ -22,7 +22,7 @@ RECURSE( kmp/ut mapped_file mapped_file/ut - mbitmap + mbitmap omni text_norm omni/print_omni diff --git a/library/cpp/digest/old_crc/crc.h b/library/cpp/digest/old_crc/crc.h index ef548cea35..4a3ce6d05e 100644 --- a/library/cpp/digest/old_crc/crc.h +++ b/library/cpp/digest/old_crc/crc.h @@ -20,7 +20,7 @@ inline ui16 crc16(const char* buf, size_t buflen, ui32 crcinit = CRC16INIT) { } struct IdTR { - Y_FORCE_INLINE static ui8 T(ui8 a) { + Y_FORCE_INLINE static ui8 T(ui8 a) { return a; } }; diff --git a/library/cpp/lfalloc/lf_allocX64.h b/library/cpp/lfalloc/lf_allocX64.h index 613cb8dab3..fd2a906d6f 100644 --- a/library/cpp/lfalloc/lf_allocX64.h +++ b/library/cpp/lfalloc/lf_allocX64.h @@ -29,7 +29,7 @@ #define PERTHREAD __declspec(thread) #define _win_ -#define Y_FORCE_INLINE __forceinline +#define Y_FORCE_INLINE __forceinline using TAtomic = volatile long; @@ -293,7 +293,7 @@ enum ELFAllocCounter { CT_MAX }; -static Y_FORCE_INLINE void IncrementCounter(ELFAllocCounter counter, size_t value); +static Y_FORCE_INLINE void IncrementCounter(ELFAllocCounter counter, size_t value); ////////////////////////////////////////////////////////////////////////// enum EMMapMode { @@ -1011,20 +1011,20 @@ struct TLocalCounter { int Updates; TAtomic* Parent; - Y_FORCE_INLINE void Init(TAtomic* parent) { + Y_FORCE_INLINE void Init(TAtomic* parent) { Parent = parent; Value = 0; Updates = 0; } - Y_FORCE_INLINE void Increment(size_t value) { + Y_FORCE_INLINE void Increment(size_t value) { Value += value; if (++Updates > MAX_LOCAL_UPDATES || Value > MAX_LOCAL_DELTA) { Flush(); } } - Y_FORCE_INLINE void Flush() { + Y_FORCE_INLINE void Flush() { AtomicAdd(*Parent, Value); Value = 0; Updates = 0; diff --git a/library/cpp/logger/system.h b/library/cpp/logger/system.h index dfa361ba66..b8c60b3023 100644 --- a/library/cpp/logger/system.h +++ b/library/cpp/logger/system.h @@ -11,7 +11,7 @@ SysLogInstance().ResetBackend(THolder<TLogBackend>( \ (ident) ? (TLogBackend*)(new TSysLogBackend((ident), (facility), (flags))) : (TLogBackend*)(new TNullLogBackend())));\ } \ - } Y_CAT(loginit, __LINE__); + } Y_CAT(loginit, __LINE__); #define YSYSLOGINIT(ident, facility) YSYSLOGINIT_FLAGS((ident), (facility), 0) diff --git a/library/cpp/packedtypes/packed.h b/library/cpp/packedtypes/packed.h index d5d617613e..88cff26ae2 100644 --- a/library/cpp/packedtypes/packed.h +++ b/library/cpp/packedtypes/packed.h @@ -52,15 +52,15 @@ struct TZCMemoryInput_traits { return get<ui8>(in); } - static ui16 Y_FORCE_INLINE get_16(TZCMemoryInput& in) { + static ui16 Y_FORCE_INLINE get_16(TZCMemoryInput& in) { return get<ui16>(in); } - static ui32 Y_FORCE_INLINE get_32(TZCMemoryInput& in) { + static ui32 Y_FORCE_INLINE get_32(TZCMemoryInput& in) { return get<ui32>(in); } - static int Y_FORCE_INLINE is_good(TZCMemoryInput&) { + static int Y_FORCE_INLINE is_good(TZCMemoryInput&) { return 1; } }; diff --git a/library/cpp/sse/sse2neon.h b/library/cpp/sse/sse2neon.h index 8901c5a9d7..695dbd3041 100644 --- a/library/cpp/sse/sse2neon.h +++ b/library/cpp/sse/sse2neon.h @@ -165,12 +165,12 @@ template <typename TValue> struct TBaseWrapper { TValue Value; - Y_FORCE_INLINE + Y_FORCE_INLINE operator TValue&() { return Value; } - Y_FORCE_INLINE + Y_FORCE_INLINE operator const TValue&() const { return Value; } @@ -179,7 +179,7 @@ struct TBaseWrapper { template <typename TOp, typename TFunc, TFunc* func, typename TDup, TDup* dupfunc> struct TWrapperSingleDup: public TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE TWrapperSingleDup(const __m128i& op, const int shift) { TQType<TOp>::As(Value) = func(TQType<TOp>::As(op), dupfunc(shift)); } @@ -188,7 +188,7 @@ struct TWrapperSingleDup: public TBaseWrapper<__m128i> { template <typename TOp, typename TFunc, TFunc* func, typename TDup, TDup* dupfunc> struct TWrapperSingleNegDup: public TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE TWrapperSingleNegDup(const __m128i& op, const int shift) { TQType<TOp>::As(Value) = func(TQType<TOp>::As(op), dupfunc(-shift)); } @@ -267,7 +267,7 @@ using _mm_slli_epi64 = template <typename TOp, typename TFunc, TFunc* func, typename... TParams> struct TWrapperDual : TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE TWrapperDual(const __m128i& op1, const __m128i& op2, TParams... params) { TQType<TOp>::As(Value) = (TOp) func(TQType<TOp>::As(op1), @@ -278,7 +278,7 @@ struct TWrapperDual : TBaseWrapper<__m128i> { template <typename TOp, typename TFunc, TFunc* func, typename... TParams> struct TWrapperDualSwap : TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE TWrapperDualSwap(const __m128i& op1, const __m128i& op2, TParams... params) { TQType<TOp>::As(Value) = func(TQType<TOp>::As(op2), @@ -289,7 +289,7 @@ struct TWrapperDualSwap : TBaseWrapper<__m128i> { template <typename TOp, typename TFunc, TFunc* func, typename TArgument = __m128> struct TWrapperDualF : TBaseWrapper<TArgument> { - Y_FORCE_INLINE + Y_FORCE_INLINE TWrapperDualF(const TArgument& op1, const TArgument& op2) { TQType<TOp>::As(TBaseWrapper<TArgument>::Value) = (TOp) func(TQType<TOp>::As(op1), TQType<TOp>::As(op2)); } @@ -412,7 +412,7 @@ _mm_store_si128(__m128i* ptr, const __m128i& op) { template <typename TOp, typename TFunc, TFunc* func, typename... TParams> struct TWrapperSimple : TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE TWrapperSimple(TParams... params) { TQType<TOp>::As(Value) = func(params...); } @@ -420,7 +420,7 @@ struct TWrapperSimple : TBaseWrapper<__m128i> { template <typename TOp, typename TFunc, TFunc* func, typename... TParams> struct TWrapperSimpleF : TBaseWrapper<__m128> { - Y_FORCE_INLINE + Y_FORCE_INLINE TWrapperSimpleF(TParams... params) { TQType<TOp>::As(Value) = func(params...); } @@ -434,14 +434,14 @@ using _mm_set1_epi32 = TWrapperSimple<int32x4_t, decltype(vdupq_n_s32), vdupq_n_s32, const ui32>; struct _mm_setzero_si128 : TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE _mm_setzero_si128() { TQType<uint64x2_t>::As(Value) = vdupq_n_u64(0); } }; struct _mm_loadl_epi64 : TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE _mm_loadl_epi64(const __m128i* p) { uint64x1_t im = vld1_u64((const uint64_t*)p); TQType<uint64x2_t>::As(Value) = vcombine_u64(im, vdup_n_u64(0)); @@ -449,7 +449,7 @@ struct _mm_loadl_epi64 : TBaseWrapper<__m128i> { }; struct _mm_storel_epi64 : TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE _mm_storel_epi64(__m128i* a, __m128i op) { vst1_u64((uint64_t*)a, vget_low_u64(op.AsUi64x2)); } @@ -502,7 +502,7 @@ _mm_movemask_epi8(const __m128i& op) { template <int imm> struct THelper_mm_srli_si128 : TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE THelper_mm_srli_si128(const __m128i a) { const auto zero = vdupq_n_u8(0); TQType<uint8x16_t>::As(Value) = vextq_u8(a.AsUi8x16, zero, imm); @@ -533,7 +533,7 @@ inline uint8x16_t vextq_u8_function<16>(uint8x16_t /* a */, uint8x16_t b) { template <int imm> struct THelper_mm_slli_si128 : TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE THelper_mm_slli_si128(const __m128i a) { auto zero = vdupq_n_u8(0); TQType<uint8x16_t>::As(Value) = vextq_u8_function<16 - imm>(zero, a.AsUi8x16); @@ -547,7 +547,7 @@ Y_FORCE_INLINE int _mm_cvtsi128_si32(const __m128i& op) { } struct _mm_set_epi16 : TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE _mm_set_epi16(const short w7, const short w6, const short w5, const short w4, const short w3, const short w2, @@ -571,7 +571,7 @@ struct _mm_setr_epi16 : TBaseWrapper<__m128i> { }; struct _mm_set_epi32 : TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE _mm_set_epi32(const int x3, const int x2, const int x1, const int x0) { int32x2_t d0 = {x0, x1}; @@ -591,7 +591,7 @@ struct _mm_setr_epi32 : TBaseWrapper<__m128i> { }; struct _mm_cvtsi32_si128 : TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE _mm_cvtsi32_si128(int op) { auto zero = vdupq_n_s32(0); TQType<int32x4_t>::As(Value) = vsetq_lane_s32(op, zero, 0); @@ -610,7 +610,7 @@ template <typename TOpOut, typename TOpIn, typename TFunc, TFunc* func, typename TCombine, TCombine* combine> struct TCombineWrapper : TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE TCombineWrapper(const __m128i op1, const __m128i op2) { TQType<TOpOut>::As(Value) = combine(func(TQType<TOpIn>::As(op1)), @@ -634,7 +634,7 @@ using _mm_packus_epi16 = template <typename TOpOut, typename TOpIn, typename TFunc, TFunc* func, typename... TParams> struct TScalarOutWrapper : TBaseWrapper<TOpOut> { - Y_FORCE_INLINE + Y_FORCE_INLINE TScalarOutWrapper(const __m128i op, TParams... params) { TBaseWrapper<TOpOut>::Value = func(TQType<TOpIn>::As(op), params...); @@ -667,7 +667,7 @@ long long extract_epi64_arm(__m128i arg) { #define _mm_extract_epi64(op, imm) extract_epi64_arm<imm>(op) #define _mm_extract_ps(op, imm) _mm_extract_epi32(op, imm) -static Y_FORCE_INLINE +static Y_FORCE_INLINE __m128i _mm_mul_epu32(__m128i op1, __m128i op2) { __m128i result; uint32x4_t r1 = vuzp1q_u32(op1.AsUi32x4, op2.AsUi32x4); @@ -728,7 +728,7 @@ using _mm_set_ps1 = TWrapperSimpleF<float32x4_t, decltype(vdupq_n_f32), vdupq_n_f32, const float>; struct _mm_setzero_ps : TBaseWrapper<__m128> { - Y_FORCE_INLINE + Y_FORCE_INLINE _mm_setzero_ps() { TQType<float32x4_t>::As(Value) = vdupq_n_f32(0.); } @@ -759,7 +759,7 @@ Y_FORCE_INLINE void _mm_store_ps(float* ptr, const __m128& op) { } struct _mm_set_ps : TBaseWrapper<__m128> { - Y_FORCE_INLINE + Y_FORCE_INLINE _mm_set_ps(const float x3, const float x2, const float x1, const float x0) { float32x2_t d0 = {x0, x1}; @@ -803,7 +803,7 @@ using _mm_mul_pd = TWrapperDualF<float64x2_t, decltype(vmulq_f64), vmulq_f64, __ using _mm_div_pd = TWrapperDualF<float64x2_t, decltype(vdivq_f64), vdivq_f64, __m128d>; struct _mm_and_ps : TBaseWrapper<__m128> { - Y_FORCE_INLINE + Y_FORCE_INLINE _mm_and_ps(const __m128& op1, const __m128& op2) { TQType<uint64x2_t>::As(Value) = vandq_u64(TQType<uint64x2_t>::As(op1), @@ -842,7 +842,7 @@ Y_FORCE_INLINE __m128i _mm_castps_si128(__m128 op) { template <typename TOpOut, typename TOpIn, typename TFunc, TFunc* func, typename... TParams> struct TCvtS2FWrapperSingle : TBaseWrapper<__m128> { - Y_FORCE_INLINE + Y_FORCE_INLINE TCvtS2FWrapperSingle(const __m128i& op, TParams... params) { TQType<TOpOut>::As(Value) = func(TQType<TOpIn>::As(op), params...); @@ -856,7 +856,7 @@ using _mm_cvtepi32_ps = template <typename TOpOut, typename TOpIn, typename TFunc, TFunc* func, typename... TParams> struct TCvtF2SWrapperSingle : TBaseWrapper<__m128i> { - Y_FORCE_INLINE + Y_FORCE_INLINE TCvtF2SWrapperSingle(const __m128& op, TParams... params) { TQType<TOpOut>::As(Value) = func(TQType<TOpIn>::As(op), params...); @@ -887,7 +887,7 @@ _mm_movemask_ps(const __m128& op) { return vaddvq_u32(bits); } -Y_FORCE_INLINE i64 _mm_cvtsi128_si64(__m128i a) { +Y_FORCE_INLINE i64 _mm_cvtsi128_si64(__m128i a) { return vgetq_lane_s64(a.AsSi64x2, 0); } diff --git a/library/cpp/streams/zc_memory_input/zc_memory_input.h b/library/cpp/streams/zc_memory_input/zc_memory_input.h index 61a6686894..c939d8e426 100644 --- a/library/cpp/streams/zc_memory_input/zc_memory_input.h +++ b/library/cpp/streams/zc_memory_input/zc_memory_input.h @@ -21,7 +21,7 @@ public: } /// if there's 'size' data read it, otherwise just return false - Y_FORCE_INLINE bool ReadFixed(const char*& buf, size_t size) { + Y_FORCE_INLINE bool ReadFixed(const char*& buf, size_t size) { if (Avail() >= size) { buf = Buf(); Reset(Buf() + size, Avail() - size); @@ -42,7 +42,7 @@ public: } template <class T> - Y_FORCE_INLINE void ReadPOD(T& x) { + Y_FORCE_INLINE void ReadPOD(T& x) { x = LoadPOD<T>(); } }; diff --git a/library/cpp/testing/unittest/utmain.cpp b/library/cpp/testing/unittest/utmain.cpp index afac0afe09..305bc6b40f 100644 --- a/library/cpp/testing/unittest/utmain.cpp +++ b/library/cpp/testing/unittest/utmain.cpp @@ -55,7 +55,7 @@ class TNullTraceWriterProcessor: public ITestSuiteProcessor { class TTraceWriterProcessor: public ITestSuiteProcessor { public: - inline TTraceWriterProcessor(const char* traceFilePath, EOpenMode mode) + inline TTraceWriterProcessor(const char* traceFilePath, EOpenMode mode) : PrevTime(TInstant::Now()) { TraceFile = new TUnbufferedFileOutput(TFile(traceFilePath, mode | WrOnly | Seq)); diff --git a/util/charset/wide.h b/util/charset/wide.h index 2d28f33d24..04e6928aab 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 983bf55341..4ea765b94b 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 7c8e5ffe6b..d8f3233e73 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 0c3c8d3dbb..6b519b430a 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 4f763ba366..29287668bc 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 a8a1bce688..712331007b 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 f49ebc9638..87d6102ee5 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 25d2f50ba3..245b2cf6d2 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 39b01401b4..bfe0c67d68 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 7ba6fc71bf..1ac60ac7d3 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 42d2c6e704..f77d182460 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 518eb720b5..2db15fc59b 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 0591c63402..a1f5921d42 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 2bdc87658b..0551d58770 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 1179811618..8cd8aa6917 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 994ce78cea..f1e137181d 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 02700b1659..b373edcc46 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 5a800c288f..dcd7abea38 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 018878bb17..4a261d020c 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 268051cd8a..9502e159b6 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 { diff --git a/ydb/core/util/bits.h b/ydb/core/util/bits.h index 90101ceb4d..0031941841 100644 --- a/ydb/core/util/bits.h +++ b/ydb/core/util/bits.h @@ -21,7 +21,7 @@ namespace NKikimr { // from gcc manual: // Returns the number of leading 0-bits in x, starting at the most significant bit position. // If x is 0, the result is undefined. - Y_FORCE_INLINE unsigned int Clz(unsigned int v) { + Y_FORCE_INLINE unsigned int Clz(unsigned int v) { #ifdef __GNUC__ return __builtin_clz(v); #elif defined(_MSC_VER) && defined(_64_) diff --git a/ydb/core/util/tuples.h b/ydb/core/util/tuples.h index c1f623955f..0ca0689198 100644 --- a/ydb/core/util/tuples.h +++ b/ydb/core/util/tuples.h @@ -1,6 +1,6 @@ #pragma once #include <util/digest/multi.h> -#include <util/str_stl.h> +#include <util/str_stl.h> #include <util/stream/output.h> #include <math.h> #include <numeric> diff --git a/ydb/library/yql/ast/yql_ast.cpp b/ydb/library/yql/ast/yql_ast.cpp index a2e9d3cbb6..16e521d901 100644 --- a/ydb/library/yql/ast/yql_ast.cpp +++ b/ydb/library/yql/ast/yql_ast.cpp @@ -450,17 +450,17 @@ namespace { const char* begin = str.data(); do { ui32 count = 0; - for (; idx < str.length() && str[idx] == '@'; ++idx) { - ++count; - } + for (; idx < str.length() && str[idx] == '@'; ++idx) { + ++count; + } if (count % 2 == 0) { out.Write(begin, idx - (begin - str.data()) - count); begin = str.data() + idx; - while (count--) { + while (count--) { out.Write(TStringBuf("@@")); - } + } } idx = str.find('@', idx); } while (idx != TString::npos); diff --git a/ydb/library/yql/core/yql_library_compiler.cpp b/ydb/library/yql/core/yql_library_compiler.cpp index 880b351620..79296792e6 100644 --- a/ydb/library/yql/core/yql_library_compiler.cpp +++ b/ydb/library/yql/core/yql_library_compiler.cpp @@ -50,7 +50,7 @@ bool ReplaceNodes(TExprNode& node, const TNodeOnNodeOwnedMap& replaces, bool& ha TString Load(const TString& path) { - TFile file(path, EOpenModeFlag::RdOnly); + TFile file(path, EOpenModeFlag::RdOnly); if (file.GetLength() <= 0) return TString(); std::vector<TString::value_type> buffer(file.GetLength()); diff --git a/ydb/library/yql/minikql/mkql_node_serialization.cpp b/ydb/library/yql/minikql/mkql_node_serialization.cpp index bf12f28d12..e314f38cd6 100644 --- a/ydb/library/yql/minikql/mkql_node_serialization.cpp +++ b/ydb/library/yql/minikql/mkql_node_serialization.cpp @@ -938,11 +938,11 @@ namespace { } } - Y_FORCE_INLINE void Write(char c) { + Y_FORCE_INLINE void Write(char c) { Out.append(c); } - Y_FORCE_INLINE void WriteMany(const void* buf, size_t len) { + Y_FORCE_INLINE void WriteMany(const void* buf, size_t len) { Out.AppendNoAlias((const char*)buf, len); } @@ -1052,14 +1052,14 @@ namespace { THROW yexception() << "Serialized data is corrupted"; } - Y_FORCE_INLINE char Read() { + Y_FORCE_INLINE char Read() { if (Current == End) ThrowNoData(); return *Current++; } - Y_FORCE_INLINE const char* ReadMany(ui32 count) { + Y_FORCE_INLINE const char* ReadMany(ui32 count) { if (Current + count > End) ThrowNoData(); |