diff options
author | sandello <sandello@yandex-team.ru> | 2022-02-10 16:49:52 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:52 +0300 |
commit | 0cdbcf332f1f329f0a3d6759462ad71e7867ac08 (patch) | |
tree | 6866207854e212f8179cb77bd1e2435e49743f66 /library/cpp/yt | |
parent | 3f5911a056d3dbc4bfd724740244a3a9c11575ef (diff) | |
download | ydb-0cdbcf332f1f329f0a3d6759462ad71e7867ac08.tar.gz |
Restoring authorship annotation for <sandello@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yt')
-rw-r--r-- | library/cpp/yt/coding/varint-inl.h | 16 | ||||
-rw-r--r-- | library/cpp/yt/coding/varint.h | 16 | ||||
-rw-r--r-- | library/cpp/yt/coding/zig_zag.h | 26 | ||||
-rw-r--r-- | library/cpp/yt/memory/blob.cpp | 2 | ||||
-rw-r--r-- | library/cpp/yt/memory/intrusive_ptr.h | 166 | ||||
-rw-r--r-- | library/cpp/yt/memory/leaky_singleton.h | 2 | ||||
-rw-r--r-- | library/cpp/yt/memory/ref.cpp | 18 | ||||
-rw-r--r-- | library/cpp/yt/memory/ref.h | 72 | ||||
-rw-r--r-- | library/cpp/yt/memory/ref_counted.h | 4 | ||||
-rw-r--r-- | library/cpp/yt/misc/port.h | 4 | ||||
-rw-r--r-- | library/cpp/yt/misc/property.h | 2 | ||||
-rw-r--r-- | library/cpp/yt/string/format-inl.h | 6 | ||||
-rw-r--r-- | library/cpp/yt/string/format.h | 2 | ||||
-rw-r--r-- | library/cpp/yt/string/string.cpp | 16 | ||||
-rw-r--r-- | library/cpp/yt/string/string.h | 22 | ||||
-rw-r--r-- | library/cpp/yt/yson_string/string.cpp | 2 | ||||
-rw-r--r-- | library/cpp/yt/yson_string/string.h | 2 |
17 files changed, 189 insertions, 189 deletions
diff --git a/library/cpp/yt/coding/varint-inl.h b/library/cpp/yt/coding/varint-inl.h index f0a09e9d30..ade6cd98a3 100644 --- a/library/cpp/yt/coding/varint-inl.h +++ b/library/cpp/yt/coding/varint-inl.h @@ -29,7 +29,7 @@ Y_FORCE_INLINE int WriteVarUint64Impl(TWriteCallback doWrite, ui64 value) } // These are optimized versions of these Read/Write functions in protobuf/io/coded_stream.cc. -Y_FORCE_INLINE int WriteVarUint64(IOutputStream* output, ui64 value) +Y_FORCE_INLINE int WriteVarUint64(IOutputStream* output, ui64 value) { return WriteVarUint64Impl([&] (ui8 byte) { output->Write(byte); @@ -51,7 +51,7 @@ Y_FORCE_INLINE int WriteVarUint32Impl(TOutput output, ui32 value) return WriteVarUint64(output, static_cast<ui64>(value)); } -Y_FORCE_INLINE int WriteVarUint32(IOutputStream* output, ui32 value) +Y_FORCE_INLINE int WriteVarUint32(IOutputStream* output, ui32 value) { return WriteVarUint32Impl(output, value); } @@ -69,7 +69,7 @@ Y_FORCE_INLINE int WriteVarInt32Impl(TOutput output, i32 value) return WriteVarUint64(output, static_cast<ui64>(ZigZagEncode32(value))); } -Y_FORCE_INLINE int WriteVarInt32(IOutputStream* output, i32 value) +Y_FORCE_INLINE int WriteVarInt32(IOutputStream* output, i32 value) { return WriteVarInt32Impl(output, value); } @@ -87,7 +87,7 @@ Y_FORCE_INLINE int WriteVarInt64Impl(TOutput output, i64 value) return WriteVarUint64(output, static_cast<ui64>(ZigZagEncode64(value))); } -Y_FORCE_INLINE int WriteVarInt64(IOutputStream* output, i64 value) +Y_FORCE_INLINE int WriteVarInt64(IOutputStream* output, i64 value) { return WriteVarInt64Impl(output, value); } @@ -119,7 +119,7 @@ Y_FORCE_INLINE int ReadVarUint64Impl(TReadCallback doRead, ui64* value) return count; } -Y_FORCE_INLINE int ReadVarUint64(IInputStream* input, ui64* value) +Y_FORCE_INLINE int ReadVarUint64(IInputStream* input, ui64* value) { return ReadVarUint64Impl([&] () { char byte; @@ -165,7 +165,7 @@ Y_FORCE_INLINE int ReadVarUint32Impl(ui32* value, Args... args) return bytesRead; } -Y_FORCE_INLINE int ReadVarUint32(IInputStream* input, ui32* value) +Y_FORCE_INLINE int ReadVarUint32(IInputStream* input, ui32* value) { return ReadVarUint32Impl(value, input); } @@ -194,7 +194,7 @@ Y_FORCE_INLINE int ReadVarInt32Impl(i32* value, Args... args) return bytesRead; } -Y_FORCE_INLINE int ReadVarInt32(IInputStream* input, i32* value) +Y_FORCE_INLINE int ReadVarInt32(IInputStream* input, i32* value) { return ReadVarInt32Impl(value, input); } @@ -220,7 +220,7 @@ Y_FORCE_INLINE int ReadVarInt64Impl(i64* value, Args... args) return bytesRead; } -Y_FORCE_INLINE int ReadVarInt64(IInputStream* input, i64* value) +Y_FORCE_INLINE int ReadVarInt64(IInputStream* input, i64* value) { return ReadVarInt64Impl(value, input); } diff --git a/library/cpp/yt/coding/varint.h b/library/cpp/yt/coding/varint.h index c5399f8b06..6914c1d692 100644 --- a/library/cpp/yt/coding/varint.h +++ b/library/cpp/yt/coding/varint.h @@ -20,10 +20,10 @@ constexpr size_t MaxVarUint32Size = (8 * sizeof(ui32) - 1) / 7 + 1; // Various functions to read/write varints. // Returns the number of bytes written. -int WriteVarUint64(IOutputStream* output, ui64 value); -int WriteVarUint32(IOutputStream* output, ui32 value); -int WriteVarInt32(IOutputStream* output, i32 value); -int WriteVarInt64(IOutputStream* output, i64 value); +int WriteVarUint64(IOutputStream* output, ui64 value); +int WriteVarUint32(IOutputStream* output, ui32 value); +int WriteVarInt32(IOutputStream* output, i32 value); +int WriteVarInt64(IOutputStream* output, i64 value); int WriteVarUint64(char* output, ui64 value); int WriteVarUint32(char* output, ui32 value); @@ -31,10 +31,10 @@ int WriteVarInt32(char* output, i32 value); int WriteVarInt64(char* output, i64 value); // Returns the number of bytes read. -int ReadVarUint64(IInputStream* input, ui64* value); -int ReadVarUint32(IInputStream* input, ui32* value); -int ReadVarInt32(IInputStream* input, i32* value); -int ReadVarInt64(IInputStream* input, i64* value); +int ReadVarUint64(IInputStream* input, ui64* value); +int ReadVarUint32(IInputStream* input, ui32* value); +int ReadVarInt32(IInputStream* input, i32* value); +int ReadVarInt64(IInputStream* input, i64* value); int ReadVarUint64(const char* input, ui64* value); int ReadVarUint32(const char* input, ui32* value); diff --git a/library/cpp/yt/coding/zig_zag.h b/library/cpp/yt/coding/zig_zag.h index aa6d425a1c..2cd19f85a1 100644 --- a/library/cpp/yt/coding/zig_zag.h +++ b/library/cpp/yt/coding/zig_zag.h @@ -1,23 +1,23 @@ -#pragma once - +#pragma once + #include <util/system/types.h> - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + // These Functions provide coding of integers with property: 0 <= f(x) <= 2 * |x| // Actually taken 'as is' from protobuf/wire_format_lite.h - + ui32 ZigZagEncode32(i32 n); i32 ZigZagDecode32(ui32 n); - + ui64 ZigZagEncode64(i64 n); i64 ZigZagDecode64(ui64 n); - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT #define ZIG_ZAG_INL_H_ #include "zig_zag-inl.h" diff --git a/library/cpp/yt/memory/blob.cpp b/library/cpp/yt/memory/blob.cpp index 86000b033b..1a332a576f 100644 --- a/library/cpp/yt/memory/blob.cpp +++ b/library/cpp/yt/memory/blob.cpp @@ -161,7 +161,7 @@ void TBlob::Allocate(size_t newCapacity) TRefCountedTrackerFacade::AllocateSpace(TagCookie_, newCapacity); #endif } - + void TBlob::Reallocate(size_t newCapacity) { if (!Begin_) { diff --git a/library/cpp/yt/memory/intrusive_ptr.h b/library/cpp/yt/memory/intrusive_ptr.h index 3dead7db1d..71d1e7c90c 100644 --- a/library/cpp/yt/memory/intrusive_ptr.h +++ b/library/cpp/yt/memory/intrusive_ptr.h @@ -13,9 +13,9 @@ namespace NYT { //////////////////////////////////////////////////////////////////////////////// template <class T> -class TIntrusivePtr -{ -public: +class TIntrusivePtr +{ +public: typedef T TUnderlying; constexpr TIntrusivePtr() noexcept @@ -34,67 +34,67 @@ public: */ TIntrusivePtr(T* obj, bool addReference = true) noexcept : T_(obj) - { + { if (T_ && addReference) { Ref(T_); } } - //! Copy constructor. + //! Copy constructor. TIntrusivePtr(const TIntrusivePtr& other) noexcept : T_(other.Get()) - { + { if (T_) { Ref(T_); - } - } + } + } //! Copy constructor with an upcast. template <class U, class = typename std::enable_if_t<std::is_convertible_v<U*, T*>>> TIntrusivePtr(const TIntrusivePtr<U>& other) noexcept - : T_(other.Get()) - { + : T_(other.Get()) + { static_assert( std::is_base_of_v<TRefCountedBase, T>, "Cast allowed only for types derived from TRefCountedBase"); if (T_) { Ref(T_); } - } + } - //! Move constructor. + //! Move constructor. TIntrusivePtr(TIntrusivePtr&& other) noexcept : T_(other.Get()) - { + { other.T_ = nullptr; - } - + } + //! Move constructor with an upcast. template <class U, class = typename std::enable_if_t<std::is_convertible_v<U*, T*>>> TIntrusivePtr(TIntrusivePtr<U>&& other) noexcept - : T_(other.Get()) - { + : T_(other.Get()) + { static_assert( std::is_base_of_v<TRefCountedBase, T>, "Cast allowed only for types derived from TRefCountedBase"); other.T_ = nullptr; - } - - //! Destructor. - ~TIntrusivePtr() - { + } + + //! Destructor. + ~TIntrusivePtr() + { if (T_) { Unref(T_); } - } + } - //! Copy assignment operator. + //! Copy assignment operator. TIntrusivePtr& operator=(const TIntrusivePtr& other) noexcept - { - TIntrusivePtr(other).Swap(*this); - return *this; - } - + { + TIntrusivePtr(other).Swap(*this); + return *this; + } + //! Copy assignment operator with an upcast. template <class U> TIntrusivePtr& operator=(const TIntrusivePtr<U>& other) noexcept @@ -109,13 +109,13 @@ public: return *this; } - //! Move assignment operator. + //! Move assignment operator. TIntrusivePtr& operator=(TIntrusivePtr&& other) noexcept - { + { TIntrusivePtr(std::move(other)).Swap(*this); - return *this; - } - + return *this; + } + //! Move assignment operator with an upcast. template <class U> TIntrusivePtr& operator=(TIntrusivePtr<U>&& other) noexcept @@ -132,22 +132,22 @@ public: //! Drop the pointer. void Reset() // noexcept - { - TIntrusivePtr().Swap(*this); - } - + { + TIntrusivePtr().Swap(*this); + } + //! Replace the pointer with a specified one. void Reset(T* p) // noexcept - { - TIntrusivePtr(p).Swap(*this); - } - + { + TIntrusivePtr(p).Swap(*this); + } + //! Returns the pointer. T* Get() const noexcept { - return T_; - } - + return T_; + } + //! Returns the pointer and releases the ownership. T* Release() noexcept { @@ -157,17 +157,17 @@ public: } T& operator*() const noexcept - { + { YT_ASSERT(T_); - return *T_; - } - + return *T_; + } + T* operator->() const noexcept - { + { YT_ASSERT(T_); return T_; - } - + } + explicit operator bool() const noexcept { return T_ != nullptr; @@ -176,12 +176,12 @@ public: //! Swap the pointer with the other one. void Swap(TIntrusivePtr& r) noexcept { - DoSwap(T_, r.T_); - } - -private: + DoSwap(T_, r.T_); + } + +private: template <class U> - friend class TIntrusivePtr; + friend class TIntrusivePtr; T* T_ = nullptr; }; @@ -268,59 +268,59 @@ bool operator>(const TIntrusivePtr<T>& lhs, const TIntrusivePtr<T>& rhs) } template <class T, class U> -bool operator==(const TIntrusivePtr<T>& lhs, const TIntrusivePtr<U>& rhs) -{ +bool operator==(const TIntrusivePtr<T>& lhs, const TIntrusivePtr<U>& rhs) +{ static_assert( std::is_convertible_v<U*, T*>, "U* must be convertible to T*"); - return lhs.Get() == rhs.Get(); -} - + return lhs.Get() == rhs.Get(); +} + template <class T, class U> -bool operator!=(const TIntrusivePtr<T>& lhs, const TIntrusivePtr<U>& rhs) -{ +bool operator!=(const TIntrusivePtr<T>& lhs, const TIntrusivePtr<U>& rhs) +{ static_assert( std::is_convertible_v<U*, T*>, "U* must be convertible to T*"); - return lhs.Get() != rhs.Get(); -} - + return lhs.Get() != rhs.Get(); +} + template <class T, class U> bool operator==(const TIntrusivePtr<T>& lhs, U* rhs) -{ +{ static_assert( std::is_convertible_v<U*, T*>, "U* must be convertible to T*"); - return lhs.Get() == rhs; -} - + return lhs.Get() == rhs; +} + template <class T, class U> bool operator!=(const TIntrusivePtr<T>& lhs, U* rhs) -{ +{ static_assert( std::is_convertible_v<U*, T*>, "U* must be convertible to T*"); - return lhs.Get() != rhs; -} - + return lhs.Get() != rhs; +} + template <class T, class U> bool operator==(T* lhs, const TIntrusivePtr<U>& rhs) -{ +{ static_assert( std::is_convertible_v<U*, T*>, "U* must be convertible to T*"); - return lhs == rhs.Get(); -} - + return lhs == rhs.Get(); +} + template <class T, class U> bool operator!=(T* lhs, const TIntrusivePtr<U>& rhs) -{ +{ static_assert( std::is_convertible_v<U*, T*>, "U* must be convertible to T*"); - return lhs != rhs.Get(); -} - + return lhs != rhs.Get(); +} + template <class T> bool operator==(std::nullptr_t, const TIntrusivePtr<T>& rhs) { diff --git a/library/cpp/yt/memory/leaky_singleton.h b/library/cpp/yt/memory/leaky_singleton.h index 03b5e51d78..9ca0bb906d 100644 --- a/library/cpp/yt/memory/leaky_singleton.h +++ b/library/cpp/yt/memory/leaky_singleton.h @@ -22,7 +22,7 @@ private: template <class T> \ friend class ::NYT::TLeakyStorage; -template <class T> +template <class T> T* LeakySingleton(); //////////////////////////////////////////////////////////////////////////////// diff --git a/library/cpp/yt/memory/ref.cpp b/library/cpp/yt/memory/ref.cpp index e8ff42e976..1ac4d4e99e 100644 --- a/library/cpp/yt/memory/ref.cpp +++ b/library/cpp/yt/memory/ref.cpp @@ -271,10 +271,10 @@ TSharedMutableRef TSharedMutableRef::MakeCopy(TRef ref, TRefCountedTypeCookie ta TString ToString(TRef ref) { - return TString(ref.Begin(), ref.End()); + return TString(ref.Begin(), ref.End()); } -TString ToString(const TMutableRef& ref) +TString ToString(const TMutableRef& ref) { return ToString(TRef(ref)); } @@ -284,17 +284,17 @@ TString ToString(const TSharedRef& ref) return ToString(TRef(ref)); } -TString ToString(const TSharedMutableRef& ref) +TString ToString(const TSharedMutableRef& ref) { return ToString(TRef(ref)); } -size_t GetPageSize() -{ - static const size_t PageSize = NSystemInfo::GetPageSize(); - return PageSize; -} - +size_t GetPageSize() +{ + static const size_t PageSize = NSystemInfo::GetPageSize(); + return PageSize; +} + size_t RoundUpToPage(size_t bytes) { static const size_t PageSize = NSystemInfo::GetPageSize(); diff --git a/library/cpp/yt/memory/ref.h b/library/cpp/yt/memory/ref.h index 73d19d9013..0f27d24c77 100644 --- a/library/cpp/yt/memory/ref.h +++ b/library/cpp/yt/memory/ref.h @@ -1,29 +1,29 @@ -#pragma once - +#pragma once + #include "new.h" #include "range.h" #include "shared_range.h" #include <type_traits> -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + // Forward declaration. class TBlob; //! A non-owning reference to a range of memory. -class TRef +class TRef : public TRange<char> -{ -public: +{ +public: //! Creates a null TRef. TRef() = default; - + //! Creates a TRef for a given block of memory. TRef(const void* data, size_t size); - + //! Creates a TRef for a given range of memory. TRef(const void* begin, const void* end); @@ -32,7 +32,7 @@ public: //! Creates a non-owning TRef for a given blob. static TRef FromBlob(const TBlob& blob); - + //! Creates a non-owning TRef for a given string. static TRef FromString(const TString& str); @@ -45,11 +45,11 @@ public: //! Creates a TRef for a part of existing range. TRef Slice(size_t startOffset, size_t endOffset) const; - + //! Compares the content for bitwise equality. static bool AreBitwiseEqual(TRef lhs, TRef rhs); }; - + //////////////////////////////////////////////////////////////////////////////// //! A non-owning reference to a mutable range of memory. @@ -77,7 +77,7 @@ public: //! Creates a non-owning TMutableRef for a given blob. static TMutableRef FromBlob(TBlob& blob); - + //! Creates a non-owning TMutableRef for a given pod structure. template <class T> static TMutableRef FromPod(T& data); @@ -88,10 +88,10 @@ public: //! Creates a TMutableRef for a part of existing range. TMutableRef Slice(size_t startOffset, size_t endOffset) const; -}; - -//////////////////////////////////////////////////////////////////////////////// - +}; + +//////////////////////////////////////////////////////////////////////////////// + //! Default tag type for memory blocks allocated via TSharedRef. /*! * Each newly allocated TSharedRef blob is associated with a tag type @@ -100,10 +100,10 @@ public: struct TDefaultSharedBlobTag { }; //! A reference to a range of memory with shared ownership. -class TSharedRef +class TSharedRef : public TSharedRange<char> -{ -public: +{ +public: //! Creates a null TSharedRef. TSharedRef() = default; @@ -141,7 +141,7 @@ public: //! Creates a TSharedRef for a given blob taking ownership of its content. static TSharedRef FromBlob(TBlob&& blob); - + //! Creates a copy of a given TRef. //! The memory is marked with a given tag. static TSharedRef MakeCopy(TRef ref, TRefCountedTypeCookie tagCookie); @@ -150,13 +150,13 @@ public: //! The memory is marked with a given tag. template <class TTag> static TSharedRef MakeCopy(TRef ref); - + //! Creates a TSharedRef for a part of existing range. TSharedRef Slice(size_t startOffset, size_t endOffset) const; - + //! Creates a TSharedRef for a part of existing range. TSharedRef Slice(const void* begin, const void* end) const; - + //! Creates a vector of slices with specified size. std::vector<TSharedRef> Split(size_t partSize) const; @@ -189,13 +189,13 @@ public: //! Converts a TSharedMutableRef to TMutableRef. operator TMutableRef() const; - + //! Converts a TSharedMutableRef to TSharedRef. operator TSharedRef() const; - + //! Converts a TSharedMutableRef to TRef. operator TRef() const; - + //! Allocates a new shared block of memory. //! The memory is marked with a given tag. @@ -301,8 +301,8 @@ private: size_t poolCapacity, TRefCountedTypeCookie cookie, As&&... args); -}; - +}; + // STL interop. const TSharedRef* begin(const TSharedRefArray& array); const TSharedRef* end(const TSharedRefArray& array); @@ -361,11 +361,11 @@ private: //////////////////////////////////////////////////////////////////////////////// TString ToString(TRef ref); -TString ToString(const TMutableRef& ref); -TString ToString(const TSharedRef& ref); -TString ToString(const TSharedMutableRef& ref); +TString ToString(const TMutableRef& ref); +TString ToString(const TSharedRef& ref); +TString ToString(const TSharedMutableRef& ref); -size_t GetPageSize(); +size_t GetPageSize(); size_t RoundUpToPage(size_t bytes); size_t GetByteSize(TRef ref); @@ -377,7 +377,7 @@ size_t GetByteSize(const std::vector<T>& parts); //////////////////////////////////////////////////////////////////////////////// -} // namespace NYT +} // namespace NYT #define REF_INL_H_ #include "ref-inl.h" diff --git a/library/cpp/yt/memory/ref_counted.h b/library/cpp/yt/memory/ref_counted.h index b683615b83..5b8b9faba7 100644 --- a/library/cpp/yt/memory/ref_counted.h +++ b/library/cpp/yt/memory/ref_counted.h @@ -6,8 +6,8 @@ #include <library/cpp/ytalloc/api/ytalloc.h> -#include <atomic> - +#include <atomic> + namespace NYT { //////////////////////////////////////////////////////////////////////////////// diff --git a/library/cpp/yt/misc/port.h b/library/cpp/yt/misc/port.h index b24ac50995..daa0ae94e6 100644 --- a/library/cpp/yt/misc/port.h +++ b/library/cpp/yt/misc/port.h @@ -1,5 +1,5 @@ -#pragma once - +#pragma once + #include <util/system/platform.h> // Check platform bitness. diff --git a/library/cpp/yt/misc/property.h b/library/cpp/yt/misc/property.h index bef8024ae1..17838bd472 100644 --- a/library/cpp/yt/misc/property.h +++ b/library/cpp/yt/misc/property.h @@ -115,7 +115,7 @@ public: \ Y_FORCE_INLINE void Set##name(type value) \ { \ name##_ = value; \ - } \ + } \ //! Defines a trivial public read-write property that is passed by value. //! All arguments after name are used as default value (via braced-init-list). diff --git a/library/cpp/yt/string/format-inl.h b/library/cpp/yt/string/format-inl.h index 5484d4a216..00c6b77496 100644 --- a/library/cpp/yt/string/format-inl.h +++ b/library/cpp/yt/string/format-inl.h @@ -109,7 +109,7 @@ inline void FormatValue(TStringBuilderBase* builder, TStringBuf value, TStringBu } } -// TString +// TString inline void FormatValue(TStringBuilderBase* builder, const TString& value, TStringBuf format) { FormatValue(builder, TStringBuf(value), format); @@ -450,7 +450,7 @@ void FormatValueViaSprintf( auto copyFormat = [] (char* destination, const char* source, int length) { int position = 0; - for (int index = 0; index < length; ++index) { + for (int index = 0; index < length; ++index) { if (IsQuotationSpecSymbol(source[index])) { continue; } @@ -730,7 +730,7 @@ TString Format( } template <class... TArgs> -TString Format( +TString Format( TStringBuf format, TArgs&&... args) { diff --git a/library/cpp/yt/string/format.h b/library/cpp/yt/string/format.h index 9708fe5906..e3a6aa9c38 100644 --- a/library/cpp/yt/string/format.h +++ b/library/cpp/yt/string/format.h @@ -33,7 +33,7 @@ namespace NYT { * * The following argument types are supported: * - * Strings (including |const char*|, |TStringBuf|, and |TString|) and chars: + * Strings (including |const char*|, |TStringBuf|, and |TString|) and chars: * Emitted as is. Fast. * * Numerics and pointers: diff --git a/library/cpp/yt/string/string.cpp b/library/cpp/yt/string/string.cpp index 7440ac3fdd..b24a2c4aa5 100644 --- a/library/cpp/yt/string/string.cpp +++ b/library/cpp/yt/string/string.cpp @@ -13,22 +13,22 @@ namespace NYT { void UnderscoreCaseToCamelCase(TStringBuilderBase* builder, TStringBuf str) { - bool first = true; + bool first = true; bool upper = true; for (char c : str) { if (c == '_') { upper = true; } else { if (upper) { - if (!std::isalpha(c) && !first) { + if (!std::isalpha(c) && !first) { builder->AppendChar('_'); - } + } c = std::toupper(c); } builder->AppendChar(c); upper = false; } - first = false; + first = false; } } @@ -43,11 +43,11 @@ void CamelCaseToUnderscoreCase(TStringBuilderBase* builder, TStringBuf str) { bool first = true; for (char c : str) { - if (std::isupper(c) && std::isalpha(c)) { + if (std::isupper(c) && std::isalpha(c)) { if (!first) { builder->AppendChar('_'); } - c = std::tolower(c); + c = std::tolower(c); } builder->AppendChar(c); first = false; @@ -63,7 +63,7 @@ TString CamelCaseToUnderscoreCase(TStringBuf str) //////////////////////////////////////////////////////////////////////////////// -TString TrimLeadingWhitespaces(const TString& str) +TString TrimLeadingWhitespaces(const TString& str) { for (int i = 0; i < static_cast<int>(str.size()); ++i) { if (str[i] != ' ') { @@ -73,7 +73,7 @@ TString TrimLeadingWhitespaces(const TString& str) return ""; } -TString Trim(const TString& str, const TString& whitespaces) +TString Trim(const TString& str, const TString& whitespaces) { size_t end = str.size(); while (end > 0) { diff --git a/library/cpp/yt/string/string.h b/library/cpp/yt/string/string.h index ae6c99caab..b2b4ef23fd 100644 --- a/library/cpp/yt/string/string.h +++ b/library/cpp/yt/string/string.h @@ -64,7 +64,7 @@ void JoinToString( } template <class TIterator, class TFormatter> -TString JoinToString( +TString JoinToString( const TIterator& begin, const TIterator& end, const TFormatter& formatter, @@ -77,7 +77,7 @@ TString JoinToString( //! A handy shortcut with default formatter. template <class TIterator> -TString JoinToString( +TString JoinToString( const TIterator& begin, const TIterator& end, TStringBuf delimiter = DefaultJoinToStringDelimiter) @@ -92,7 +92,7 @@ TString JoinToString( * \param delimiter A delimiter to be inserted between items; ", " by default. */ template <class TCollection, class TFormatter> -TString JoinToString( +TString JoinToString( const TCollection& collection, const TFormatter& formatter, TStringBuf delimiter = DefaultJoinToStringDelimiter) @@ -104,7 +104,7 @@ TString JoinToString( //! A handy shortcut with the default formatter. template <class TCollection> -TString JoinToString( +TString JoinToString( const TCollection& collection, TStringBuf delimiter = DefaultJoinToStringDelimiter) { @@ -127,13 +127,13 @@ TString ConcatToString(Ts... args) //! Converts a range of items into strings. template <class TIter, class TFormatter> -std::vector<TString> ConvertToStrings( +std::vector<TString> ConvertToStrings( const TIter& begin, const TIter& end, const TFormatter& formatter, size_t maxSize = std::numeric_limits<size_t>::max()) { - std::vector<TString> result; + std::vector<TString> result; for (auto it = begin; it != end; ++it) { TStringBuilder builder; formatter(&builder, *it); @@ -147,7 +147,7 @@ std::vector<TString> ConvertToStrings( //! A handy shortcut with the default formatter. template <class TIter> -std::vector<TString> ConvertToStrings( +std::vector<TString> ConvertToStrings( const TIter& begin, const TIter& end, size_t maxSize = std::numeric_limits<size_t>::max()) @@ -162,7 +162,7 @@ std::vector<TString> ConvertToStrings( * \param maxSize Size limit for the resulting vector. */ template <class TCollection, class TFormatter> -std::vector<TString> ConvertToStrings( +std::vector<TString> ConvertToStrings( const TCollection& collection, const TFormatter& formatter, size_t maxSize = std::numeric_limits<size_t>::max()) @@ -174,7 +174,7 @@ std::vector<TString> ConvertToStrings( //! A handy shortcut with default formatter. template <class TCollection> -std::vector<TString> ConvertToStrings( +std::vector<TString> ConvertToStrings( const TCollection& collection, size_t maxSize = std::numeric_limits<size_t>::max()) { @@ -189,8 +189,8 @@ TString UnderscoreCaseToCamelCase(TStringBuf str); void CamelCaseToUnderscoreCase(TStringBuilderBase* builder, TStringBuf str); TString CamelCaseToUnderscoreCase(TStringBuf str); -TString TrimLeadingWhitespaces(const TString& str); -TString Trim(const TString& str, const TString& whitespaces); +TString TrimLeadingWhitespaces(const TString& str); +TString Trim(const TString& str, const TString& whitespaces); //////////////////////////////////////////////////////////////////////////////// diff --git a/library/cpp/yt/yson_string/string.cpp b/library/cpp/yt/yson_string/string.cpp index 99d45e8616..7159279834 100644 --- a/library/cpp/yt/yson_string/string.cpp +++ b/library/cpp/yt/yson_string/string.cpp @@ -170,7 +170,7 @@ size_t TYsonString::ComputeHash() const //////////////////////////////////////////////////////////////////////////////// -TString ToString(const TYsonString& yson) +TString ToString(const TYsonString& yson) { return yson.ToString(); } diff --git a/library/cpp/yt/yson_string/string.h b/library/cpp/yt/yson_string/string.h index e13af37a6d..971be8c106 100644 --- a/library/cpp/yt/yson_string/string.h +++ b/library/cpp/yt/yson_string/string.h @@ -128,7 +128,7 @@ bool operator != (const TYsonString& lhs, const TYsonStringBuf& rhs); bool operator != (const TYsonStringBuf& lhs, const TYsonString& rhs); bool operator != (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs); -TString ToString(const TYsonString& yson); +TString ToString(const TYsonString& yson); TString ToString(const TYsonStringBuf& yson); //////////////////////////////////////////////////////////////////////////////// |