diff options
author | savrus <savrus@yandex-team.ru> | 2022-02-10 16:50:48 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:48 +0300 |
commit | 2056f5ae3bf6e5a65e9885e0add085c708cca5b8 (patch) | |
tree | 253bee3c01d51bffda855b0fb547d9b755f669b0 /library | |
parent | 445df920f2d83b93084aba764d98163d25598cda (diff) | |
download | ydb-2056f5ae3bf6e5a65e9885e0add085c708cca5b8.tar.gz |
Restoring authorship annotation for <savrus@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library')
-rw-r--r-- | library/cpp/yt/memory/blob.cpp | 100 | ||||
-rw-r--r-- | library/cpp/yt/memory/blob.h | 60 | ||||
-rw-r--r-- | library/cpp/yt/memory/new-inl.h | 2 | ||||
-rw-r--r-- | library/cpp/yt/memory/range.h | 10 | ||||
-rw-r--r-- | library/cpp/yt/memory/ref.h | 4 | ||||
-rw-r--r-- | library/cpp/yt/misc/property.h | 114 | ||||
-rw-r--r-- | library/cpp/yt/misc/variant.h | 2 | ||||
-rw-r--r-- | library/cpp/yt/small_containers/compact_flat_map-inl.h | 16 | ||||
-rw-r--r-- | library/cpp/yt/small_containers/compact_flat_map.h | 10 | ||||
-rw-r--r-- | library/cpp/yt/small_containers/unittests/compact_flat_map_ut.cpp | 36 | ||||
-rw-r--r-- | library/cpp/yt/string/format-inl.h | 86 | ||||
-rw-r--r-- | library/cpp/yt/string/string.cpp | 50 | ||||
-rw-r--r-- | library/cpp/yt/yson_string/string.cpp | 2 | ||||
-rw-r--r-- | library/cpp/yt/yson_string/string.h | 2 | ||||
-rw-r--r-- | library/cpp/ytalloc/api/fallback.cpp | 6 | ||||
-rw-r--r-- | library/cpp/ytalloc/api/ytalloc.h | 12 |
16 files changed, 256 insertions, 256 deletions
diff --git a/library/cpp/yt/memory/blob.cpp b/library/cpp/yt/memory/blob.cpp index 86000b033b..542592ab28 100644 --- a/library/cpp/yt/memory/blob.cpp +++ b/library/cpp/yt/memory/blob.cpp @@ -21,7 +21,7 @@ TBlob::TBlob( if (size == 0) { Reset(); } else { - Allocate(std::max(size, InitialBlobCapacity)); + Allocate(std::max(size, InitialBlobCapacity)); Size_ = size; if (initiailizeStorage) { ::memset(Begin_, 0, Size_); @@ -34,12 +34,12 @@ TBlob::TBlob( TRef data, bool pageAligned) : PageAligned_(pageAligned) -{ +{ SetTagCookie(tagCookie); - Reset(); + Reset(); Append(data); -} - +} + TBlob::TBlob(const TBlob& other) : PageAligned_(other.PageAligned_) { @@ -47,13 +47,13 @@ TBlob::TBlob(const TBlob& other) if (other.Size_ == 0) { Reset(); } else { - Allocate(std::max(InitialBlobCapacity, other.Size_)); + Allocate(std::max(InitialBlobCapacity, other.Size_)); ::memcpy(Begin_, other.Begin_, other.Size_); Size_ = other.Size_; } } -TBlob::TBlob(TBlob&& other) noexcept +TBlob::TBlob(TBlob&& other) noexcept : Begin_(other.Begin_) , Size_(other.Size_) , Capacity_(other.Capacity_) @@ -65,13 +65,13 @@ TBlob::TBlob(TBlob&& other) noexcept TBlob::~TBlob() { - Free(); + Free(); } void TBlob::Reserve(size_t newCapacity) { if (newCapacity > Capacity_) { - Reallocate(newCapacity); + Reallocate(newCapacity); } } @@ -79,13 +79,13 @@ void TBlob::Resize(size_t newSize, bool initializeStorage /*= true*/) { if (newSize > Size_) { if (newSize > Capacity_) { - size_t newCapacity; + size_t newCapacity; if (Capacity_ == 0) { - newCapacity = std::max(InitialBlobCapacity, newSize); + newCapacity = std::max(InitialBlobCapacity, newSize); } else { - newCapacity = std::max(static_cast<size_t>(Capacity_ * BlobCapacityMultiplier), newSize); + newCapacity = std::max(static_cast<size_t>(Capacity_ * BlobCapacityMultiplier), newSize); } - Reallocate(newCapacity); + Reallocate(newCapacity); } if (initializeStorage) { ::memset(Begin_ + Size_, 0, newSize - Size_); @@ -103,7 +103,7 @@ TBlob& TBlob::operator = (const TBlob& rhs) return *this; } -TBlob& TBlob::operator = (TBlob&& rhs) noexcept +TBlob& TBlob::operator = (TBlob&& rhs) noexcept { if (this != &rhs) { this->~TBlob(); @@ -151,61 +151,61 @@ char* TBlob::DoAllocate(size_t size) : NYTAlloc::Allocate(size)); } -void TBlob::Allocate(size_t newCapacity) -{ +void TBlob::Allocate(size_t newCapacity) +{ YT_VERIFY(!Begin_); Begin_ = DoAllocate(newCapacity); - Capacity_ = newCapacity; -#ifdef YT_ENABLE_REF_COUNTED_TRACKING + Capacity_ = newCapacity; +#ifdef YT_ENABLE_REF_COUNTED_TRACKING TRefCountedTrackerFacade::AllocateTagInstance(TagCookie_); TRefCountedTrackerFacade::AllocateSpace(TagCookie_, newCapacity); -#endif -} +#endif +} -void TBlob::Reallocate(size_t newCapacity) -{ +void TBlob::Reallocate(size_t newCapacity) +{ if (!Begin_) { - Allocate(newCapacity); - return; - } + Allocate(newCapacity); + return; + } char* newBegin = DoAllocate(newCapacity); ::memcpy(newBegin, Begin_, Size_); NYTAlloc::FreeNonNull(Begin_); -#ifdef YT_ENABLE_REF_COUNTED_TRACKING +#ifdef YT_ENABLE_REF_COUNTED_TRACKING TRefCountedTrackerFacade::AllocateSpace(TagCookie_, newCapacity); TRefCountedTrackerFacade::FreeSpace(TagCookie_, Capacity_); -#endif - Begin_ = newBegin; - Capacity_ = newCapacity; -} - -void TBlob::Free() -{ +#endif + Begin_ = newBegin; + Capacity_ = newCapacity; +} + +void TBlob::Free() +{ if (!Begin_) { - return; - } + return; + } NYTAlloc::FreeNonNull(Begin_); -#ifdef YT_ENABLE_REF_COUNTED_TRACKING +#ifdef YT_ENABLE_REF_COUNTED_TRACKING TRefCountedTrackerFacade::FreeTagInstance(TagCookie_); TRefCountedTrackerFacade::FreeSpace(TagCookie_, Capacity_); -#endif +#endif Reset(); -} - +} + void TBlob::SetTagCookie(TRefCountedTypeCookie tagCookie) -{ -#ifdef YT_ENABLE_REF_COUNTED_TRACKING +{ +#ifdef YT_ENABLE_REF_COUNTED_TRACKING TagCookie_ = tagCookie; -#endif -} +#endif +} void TBlob::SetTagCookie(const TBlob& other) -{ -#ifdef YT_ENABLE_REF_COUNTED_TRACKING +{ +#ifdef YT_ENABLE_REF_COUNTED_TRACKING TagCookie_ = other.TagCookie_; -#endif -} - +#endif +} + void swap(TBlob& left, TBlob& right) { if (&left != &right) { @@ -213,9 +213,9 @@ void swap(TBlob& left, TBlob& right) std::swap(left.Size_, right.Size_); std::swap(left.Capacity_, right.Capacity_); std::swap(left.PageAligned_, right.PageAligned_); -#ifdef YT_ENABLE_REF_COUNTED_TRACKING +#ifdef YT_ENABLE_REF_COUNTED_TRACKING std::swap(left.TagCookie_, right.TagCookie_); -#endif +#endif } } diff --git a/library/cpp/yt/memory/blob.h b/library/cpp/yt/memory/blob.h index 99441fb8c9..b03d526cf4 100644 --- a/library/cpp/yt/memory/blob.h +++ b/library/cpp/yt/memory/blob.h @@ -1,16 +1,16 @@ #pragma once #include "ref.h" -#include "ref_counted.h" +#include "ref_counted.h" namespace NYT { //////////////////////////////////////////////////////////////////////////////// -//! Default memory tag for TBlob. +//! Default memory tag for TBlob. struct TDefaultBlobTag { }; - + //! A home-grown optimized replacement for |std::vector<char>| suitable for carrying //! large chunks of data. /*! @@ -20,27 +20,27 @@ struct TDefaultBlobTag class TBlob { public: - //! Constructs a blob with a given size. + //! Constructs a blob with a given size. TBlob( TRefCountedTypeCookie tagCookie, size_t size, bool initiailizeStorage = true, bool pageAligned = false); - - //! Copies a chunk of memory into a new instance. + + //! Copies a chunk of memory into a new instance. TBlob( TRefCountedTypeCookie tagCookie, TRef data, bool pageAligned = false); - + //! Constructs an empty blob. - template <class TTag = TDefaultBlobTag> + template <class TTag = TDefaultBlobTag> explicit TBlob(TTag tag = {}) : TBlob(tag, 0, true, false) - { } + { } //! Constructs a blob with a given size. - template <class TTag> + template <class TTag> explicit TBlob( TTag, size_t size, @@ -51,10 +51,10 @@ public: size, initiailizeStorage, pageAligned) - { } + { } - //! Copies a chunk of memory into a new instance. - template <class TTag> + //! Copies a chunk of memory into a new instance. + template <class TTag> TBlob( TTag, TRef data, @@ -63,21 +63,21 @@ public: GetRefCountedTypeCookie<TTag>(), data, pageAligned) - { } - - //! Remind user about the tag argument. - TBlob(i32 size, bool initiailizeStorage = true) = delete; - TBlob(i64 size, bool initiailizeStorage = true) = delete; - TBlob(ui32 size, bool initiailizeStorage = true) = delete; - TBlob(ui64 size, bool initiailizeStorage = true) = delete; + { } + + //! Remind user about the tag argument. + TBlob(i32 size, bool initiailizeStorage = true) = delete; + TBlob(i64 size, bool initiailizeStorage = true) = delete; + TBlob(ui32 size, bool initiailizeStorage = true) = delete; + TBlob(ui64 size, bool initiailizeStorage = true) = delete; template <typename T, typename U> TBlob(const T*, U) = delete; - + //! Copies the data. TBlob(const TBlob& other); //! Moves the data (takes the ownership). - TBlob(TBlob&& other) noexcept; + TBlob(TBlob&& other) noexcept; //! Reclaims the memory. ~TBlob(); @@ -176,7 +176,7 @@ public: TBlob& operator = (const TBlob& rhs); //! Takes the ownership. - TBlob& operator = (TBlob&& rhs) noexcept; + TBlob& operator = (TBlob&& rhs) noexcept; //! Appends a chunk of memory to the end. void Append(const void* data, size_t size); @@ -198,15 +198,15 @@ private: size_t Capacity_ = 0; bool PageAligned_ = false; -#ifdef YT_ENABLE_REF_COUNTED_TRACKING +#ifdef YT_ENABLE_REF_COUNTED_TRACKING TRefCountedTypeCookie TagCookie_ = NullRefCountedTypeCookie; -#endif - +#endif + char* DoAllocate(size_t newCapacity); - void Allocate(size_t newCapacity); - void Reallocate(size_t newCapacity); - void Free(); - + void Allocate(size_t newCapacity); + void Reallocate(size_t newCapacity); + void Free(); + void Reset(); void SetTagCookie(TRefCountedTypeCookie tagCookie); diff --git a/library/cpp/yt/memory/new-inl.h b/library/cpp/yt/memory/new-inl.h index 0a84818516..4e8d70449c 100644 --- a/library/cpp/yt/memory/new-inl.h +++ b/library/cpp/yt/memory/new-inl.h @@ -5,7 +5,7 @@ #endif #include <library/cpp/ytalloc/api/ytalloc.h> - + namespace NYT { //////////////////////////////////////////////////////////////////////////////// diff --git a/library/cpp/yt/memory/range.h b/library/cpp/yt/memory/range.h index 6c71aa9496..316595f1f3 100644 --- a/library/cpp/yt/memory/range.h +++ b/library/cpp/yt/memory/range.h @@ -160,11 +160,11 @@ public: return Length_; } - size_t size() const - { - return Size(); - } - + size_t size() const + { + return Size(); + } + const T& operator[](size_t index) const { YT_ASSERT(index < Size()); diff --git a/library/cpp/yt/memory/ref.h b/library/cpp/yt/memory/ref.h index 73d19d9013..44d8bbbb2d 100644 --- a/library/cpp/yt/memory/ref.h +++ b/library/cpp/yt/memory/ref.h @@ -157,9 +157,9 @@ public: //! 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. + //! Creates a vector of slices with specified size. std::vector<TSharedRef> Split(size_t partSize) const; - + private: friend class TSharedRefArrayImpl; }; diff --git a/library/cpp/yt/misc/property.h b/library/cpp/yt/misc/property.h index bef8024ae1..898ee47162 100644 --- a/library/cpp/yt/misc/property.h +++ b/library/cpp/yt/misc/property.h @@ -209,26 +209,26 @@ public: \ } //////////////////////////////////////////////////////////////////////////////// - + //! Below are macro helpers for extra properties. -//! Extra properties should be used for lazy memory allocation for properties that -//! hold default values for the majority of objects. - +//! Extra properties should be used for lazy memory allocation for properties that +//! hold default values for the majority of objects. + //! Initializes extra property holder if it is not initialized. #define INITIALIZE_EXTRA_PROPERTY_HOLDER(holder) \ if (!holder##_) { \ holder##_.reset(new decltype(holder##_)::element_type()); \ } -//! Declares an extra property holder. Holder contains extra properties values. -//! Holder is not created until some property is set with a non-default value. -//! If there is no holder property getter returns default value. -#define DECLARE_EXTRA_PROPERTY_HOLDER(type, holder) \ -public: \ - Y_FORCE_INLINE bool HasCustom##holder() const \ - { \ - return static_cast<bool>(holder##_); \ - } \ +//! Declares an extra property holder. Holder contains extra properties values. +//! Holder is not created until some property is set with a non-default value. +//! If there is no holder property getter returns default value. +#define DECLARE_EXTRA_PROPERTY_HOLDER(type, holder) \ +public: \ + Y_FORCE_INLINE bool HasCustom##holder() const \ + { \ + return static_cast<bool>(holder##_); \ + } \ Y_FORCE_INLINE const type* GetCustom##holder() const \ { \ return holder##_.get(); \ @@ -241,49 +241,49 @@ public: \ { \ INITIALIZE_EXTRA_PROPERTY_HOLDER(holder) \ } \ -private: \ - std::unique_ptr<type> holder##_; \ - static const type Default##holder##_; - -//! Defines a storage for extra properties default values. -#define DEFINE_EXTRA_PROPERTY_HOLDER(class, type, holder) \ - const type class::Default##holder##_; - -//! Defines a public read-write extra property that is passed by value. -#define DEFINE_BYVAL_RW_EXTRA_PROPERTY(holder, name) \ -public: \ - Y_FORCE_INLINE decltype(holder##_->name) Get##name() const \ - { \ - if (!holder##_) { \ - return Default##holder##_.name; \ - } \ - return holder##_->name; \ - } \ - Y_FORCE_INLINE void Set##name(decltype(holder##_->name) val) \ - { \ - if (!holder##_) { \ - if (val == Default##holder##_.name) { \ - return; \ - } \ +private: \ + std::unique_ptr<type> holder##_; \ + static const type Default##holder##_; + +//! Defines a storage for extra properties default values. +#define DEFINE_EXTRA_PROPERTY_HOLDER(class, type, holder) \ + const type class::Default##holder##_; + +//! Defines a public read-write extra property that is passed by value. +#define DEFINE_BYVAL_RW_EXTRA_PROPERTY(holder, name) \ +public: \ + Y_FORCE_INLINE decltype(holder##_->name) Get##name() const \ + { \ + if (!holder##_) { \ + return Default##holder##_.name; \ + } \ + return holder##_->name; \ + } \ + Y_FORCE_INLINE void Set##name(decltype(holder##_->name) val) \ + { \ + if (!holder##_) { \ + if (val == Default##holder##_.name) { \ + return; \ + } \ INITIALIZE_EXTRA_PROPERTY_HOLDER(holder); \ - } \ - holder##_->name = val; \ - } - -//! Defines a public read-write extra property that is passed by reference. -#define DEFINE_BYREF_RW_EXTRA_PROPERTY(holder, name) \ -public: \ - Y_FORCE_INLINE const decltype(holder##_->name)& name() const \ - { \ - if (!holder##_) { \ - return Default##holder##_.name; \ - } \ - return holder##_->name; \ - } \ - Y_FORCE_INLINE decltype(holder##_->name)& Mutable##name() \ - { \ + } \ + holder##_->name = val; \ + } + +//! Defines a public read-write extra property that is passed by reference. +#define DEFINE_BYREF_RW_EXTRA_PROPERTY(holder, name) \ +public: \ + Y_FORCE_INLINE const decltype(holder##_->name)& name() const \ + { \ + if (!holder##_) { \ + return Default##holder##_.name; \ + } \ + return holder##_->name; \ + } \ + Y_FORCE_INLINE decltype(holder##_->name)& Mutable##name() \ + { \ INITIALIZE_EXTRA_PROPERTY_HOLDER(holder); \ - return holder##_->name; \ - } - -//////////////////////////////////////////////////////////////////////////////// + return holder##_->name; \ + } + +//////////////////////////////////////////////////////////////////////////////// diff --git a/library/cpp/yt/misc/variant.h b/library/cpp/yt/misc/variant.h index 27c0a2bc08..dd89e08ab3 100644 --- a/library/cpp/yt/misc/variant.h +++ b/library/cpp/yt/misc/variant.h @@ -20,7 +20,7 @@ template <class T, class... Ts> struct TVariantIndex<T, std::variant<Ts...>> : std::integral_constant<size_t, NDetail::TIndexOf<T, Ts...>::Value> { }; - + template <class T, class V> constexpr size_t VariantIndexV = TVariantIndex<T, V>::value; diff --git a/library/cpp/yt/small_containers/compact_flat_map-inl.h b/library/cpp/yt/small_containers/compact_flat_map-inl.h index 45a4dd1de3..ae28d35237 100644 --- a/library/cpp/yt/small_containers/compact_flat_map-inl.h +++ b/library/cpp/yt/small_containers/compact_flat_map-inl.h @@ -102,7 +102,7 @@ bool TCompactFlatMap<K, V, N>::contains(const K& k) const } template <class K, class V, unsigned N> -auto TCompactFlatMap<K, V, N>::insert(const value_type& value) -> std::pair<iterator, bool> +auto TCompactFlatMap<K, V, N>::insert(const value_type& value) -> std::pair<iterator, bool> { auto [rangeBegin, rangeEnd] = EqualRange(value.first); if (rangeBegin != rangeEnd) { @@ -123,13 +123,13 @@ void TCompactFlatMap<K, V, N>::insert(TInputIterator begin, TInputIterator end) } template <class K, class V, unsigned N> -template <class... TArgs> -auto TCompactFlatMap<K, V, N>::emplace(TArgs&&... args) -> std::pair<iterator, bool> -{ - return insert(value_type(std::forward<TArgs>(args)...)); -} - -template <class K, class V, unsigned N> +template <class... TArgs> +auto TCompactFlatMap<K, V, N>::emplace(TArgs&&... args) -> std::pair<iterator, bool> +{ + return insert(value_type(std::forward<TArgs>(args)...)); +} + +template <class K, class V, unsigned N> V& TCompactFlatMap<K, V, N>::operator[](const K& k) { auto [it, inserted] = insert({k, V()}); diff --git a/library/cpp/yt/small_containers/compact_flat_map.h b/library/cpp/yt/small_containers/compact_flat_map.h index 13bdc0e9da..4e0999b934 100644 --- a/library/cpp/yt/small_containers/compact_flat_map.h +++ b/library/cpp/yt/small_containers/compact_flat_map.h @@ -28,8 +28,8 @@ public: // NB: can't make this pair<const K, V> as TCompactVector requires its type // parameter to be copy-assignable. using value_type = std::pair<K, V>; - using key_type = K; - using mapped_type = V; + using key_type = K; + using mapped_type = V; private: using TStorage = TCompactVector<value_type, N>; @@ -84,9 +84,9 @@ public: template <class TInputIterator> void insert(TInputIterator begin, TInputIterator end); - template <class... TArgs> - std::pair<iterator, bool> emplace(TArgs&&... args); - + template <class... TArgs> + std::pair<iterator, bool> emplace(TArgs&&... args); + V& operator[](const K& k); void erase(const K& k); diff --git a/library/cpp/yt/small_containers/unittests/compact_flat_map_ut.cpp b/library/cpp/yt/small_containers/unittests/compact_flat_map_ut.cpp index 0b2f290692..01471f00cd 100644 --- a/library/cpp/yt/small_containers/unittests/compact_flat_map_ut.cpp +++ b/library/cpp/yt/small_containers/unittests/compact_flat_map_ut.cpp @@ -129,24 +129,24 @@ TEST(CompactFlatMapTest, Insert) EXPECT_EQ(m.find("and")->second, "trunkless"); } -TEST(CompactFlatMapTest, Emplace) -{ - auto m = CreateMap(); - - auto [it, inserted] = m.emplace("Far", "place"); - EXPECT_TRUE(inserted); - EXPECT_EQ(m.ssize(), 5); - EXPECT_NE(it, m.end()); - EXPECT_EQ(it, m.find("Far")); - EXPECT_EQ(it->second, "place"); - - auto [it2, inserted2] = m.emplace("Far", "behind"); - EXPECT_FALSE(inserted2); - EXPECT_EQ(m.ssize(), 5); - EXPECT_EQ(it2, it); - EXPECT_EQ(it->second, "place"); -} - +TEST(CompactFlatMapTest, Emplace) +{ + auto m = CreateMap(); + + auto [it, inserted] = m.emplace("Far", "place"); + EXPECT_TRUE(inserted); + EXPECT_EQ(m.ssize(), 5); + EXPECT_NE(it, m.end()); + EXPECT_EQ(it, m.find("Far")); + EXPECT_EQ(it->second, "place"); + + auto [it2, inserted2] = m.emplace("Far", "behind"); + EXPECT_FALSE(inserted2); + EXPECT_EQ(m.ssize(), 5); + EXPECT_EQ(it2, it); + EXPECT_EQ(it->second, "place"); +} + TEST(CompactFlatMapTest, Subscript) { auto m = CreateMap(); diff --git a/library/cpp/yt/string/format-inl.h b/library/cpp/yt/string/format-inl.h index 5484d4a216..9cad37997c 100644 --- a/library/cpp/yt/string/format-inl.h +++ b/library/cpp/yt/string/format-inl.h @@ -13,14 +13,14 @@ #include <library/cpp/yt/misc/enum.h> -#include <cctype> +#include <cctype> #include <optional> - + namespace NYT { //////////////////////////////////////////////////////////////////////////////// -static const char GenericSpecSymbol = 'v'; +static const char GenericSpecSymbol = 'v'; inline bool IsQuotationSpecSymbol(char symbol) { @@ -67,22 +67,22 @@ inline void FormatValue(TStringBuilderBase* builder, TStringBuf value, TStringBu padRight = alignLeft; } - bool singleQuotes = false; - bool doubleQuotes = false; - while (current < format.end()) { - if (*current == 'q') { - singleQuotes = true; - } else if (*current == 'Q') { - doubleQuotes = true; - } - ++current; - } - + bool singleQuotes = false; + bool doubleQuotes = false; + while (current < format.end()) { + if (*current == 'q') { + singleQuotes = true; + } else if (*current == 'Q') { + doubleQuotes = true; + } + ++current; + } + if (padLeft) { builder->AppendChar(' ', padding); } - - if (singleQuotes || doubleQuotes) { + + if (singleQuotes || doubleQuotes) { for (const char* valueCurrent = value.begin(); valueCurrent < value.end(); ++valueCurrent) { char ch = *valueCurrent; if (ch == '\n') { @@ -90,20 +90,20 @@ inline void FormatValue(TStringBuilderBase* builder, TStringBuf value, TStringBu } else if (ch == '\t') { builder->AppendString("\\t"); } else if (ch < PrintableASCIILow || ch > PrintableASCIIHigh) { - builder->AppendString("\\x"); - builder->AppendChar(Int2Hex[static_cast<ui8>(ch) >> 4]); - builder->AppendChar(Int2Hex[static_cast<ui8>(ch) & 0xf]); + builder->AppendString("\\x"); + builder->AppendChar(Int2Hex[static_cast<ui8>(ch) >> 4]); + builder->AppendChar(Int2Hex[static_cast<ui8>(ch) & 0xf]); } else if ((singleQuotes && ch == '\'') || (doubleQuotes && ch == '\"')) { - builder->AppendChar('\\'); + builder->AppendChar('\\'); builder->AppendChar(ch); - } else { + } else { builder->AppendChar(ch); - } - } - } else { - builder->AppendString(value); - } - + } + } + } else { + builder->AppendString(value); + } + if (padRight) { builder->AppendChar(' ', padding); } @@ -121,12 +121,12 @@ inline void FormatValue(TStringBuilderBase* builder, const char* value, TStringB FormatValue(builder, TStringBuf(value), format); } -// char +// char inline void FormatValue(TStringBuilderBase* builder, char value, TStringBuf format) -{ - FormatValue(builder, TStringBuf(&value, 1), format); -} - +{ + FormatValue(builder, TStringBuf(&value, 1), format); +} + // bool inline void FormatValue(TStringBuilderBase* builder, bool value, TStringBuf format) { @@ -138,7 +138,7 @@ inline void FormatValue(TStringBuilderBase* builder, bool value, TStringBuf form ++current; lowercase = true; } else if (IsQuotationSpecSymbol(*current)) { - ++current; + ++current; } else break; } @@ -179,7 +179,7 @@ struct TValueFormatter<TEnum, typename std::enable_if<TEnumTraits<TEnum>::IsEnum ++current; lowercase = true; } else if (IsQuotationSpecSymbol(*current)) { - ++current; + ++current; } else { break; } @@ -389,7 +389,7 @@ struct TValueFormatter<TEnumIndexedVector<E, T>> if (!firstItem) { builder->AppendString(DefaultJoinToStringDelimiter); } - FormatValue(builder, index, format); + FormatValue(builder, index, format); builder->AppendString(": "); FormatValue(builder, collection[index], format); firstItem = false; @@ -587,9 +587,9 @@ void FormatImpl( // Scan format part until stop symbol. auto argFormatBegin = current; auto argFormatEnd = argFormatBegin; - bool singleQuotes = false; - bool doubleQuotes = false; - + bool singleQuotes = false; + bool doubleQuotes = false; + while ( argFormatEnd != format.end() && *argFormatEnd != GenericSpecSymbol && // value in generic format @@ -612,11 +612,11 @@ void FormatImpl( *argFormatEnd != 'p' && *argFormatEnd != 'n') { - if (*argFormatEnd == 'q') { - singleQuotes = true; - } else if (*argFormatEnd == 'Q') { - doubleQuotes = true; - } + if (*argFormatEnd == 'q') { + singleQuotes = true; + } else if (*argFormatEnd == 'Q') { + doubleQuotes = true; + } ++argFormatEnd; } diff --git a/library/cpp/yt/string/string.cpp b/library/cpp/yt/string/string.cpp index 7440ac3fdd..886963cd5a 100644 --- a/library/cpp/yt/string/string.cpp +++ b/library/cpp/yt/string/string.cpp @@ -74,33 +74,33 @@ TString TrimLeadingWhitespaces(const TString& str) } TString Trim(const TString& str, const TString& whitespaces) -{ - size_t end = str.size(); - while (end > 0) { - size_t i = end - 1; - bool isWhitespace = false; - for (auto c : whitespaces) { - if (str[i] == c) { - isWhitespace = true; - break; - } - } - if (!isWhitespace) { - break; - } - --end; - } - - if (end == 0) { - return ""; - } - - size_t begin = str.find_first_not_of(whitespaces); +{ + size_t end = str.size(); + while (end > 0) { + size_t i = end - 1; + bool isWhitespace = false; + for (auto c : whitespaces) { + if (str[i] == c) { + isWhitespace = true; + break; + } + } + if (!isWhitespace) { + break; + } + --end; + } + + if (end == 0) { + return ""; + } + + size_t begin = str.find_first_not_of(whitespaces); YT_VERIFY(begin != TString::npos); YT_VERIFY(begin < end); - return str.substr(begin, end - begin); -} - + return str.substr(begin, end - begin); +} + //////////////////////////////////////////////////////////////////////////////// namespace { diff --git a/library/cpp/yt/yson_string/string.cpp b/library/cpp/yt/yson_string/string.cpp index 99d45e8616..39302fbb4f 100644 --- a/library/cpp/yt/yson_string/string.cpp +++ b/library/cpp/yt/yson_string/string.cpp @@ -1,7 +1,7 @@ #include "string.h" #include <library/cpp/yt/assert/assert.h> - + #include <library/cpp/yt/misc/variant.h> #include <library/cpp/yt/memory/new.h> diff --git a/library/cpp/yt/yson_string/string.h b/library/cpp/yt/yson_string/string.h index e13af37a6d..70c1d8fc0c 100644 --- a/library/cpp/yt/yson_string/string.h +++ b/library/cpp/yt/yson_string/string.h @@ -17,7 +17,7 @@ class TYsonStringBuf public: //! Constructs a null instance. TYsonStringBuf(); - + //! Constructs an instance from TYsonString. TYsonStringBuf(const TYsonString& ysonString); diff --git a/library/cpp/ytalloc/api/fallback.cpp b/library/cpp/ytalloc/api/fallback.cpp index 5880ede439..77d443161f 100644 --- a/library/cpp/ytalloc/api/fallback.cpp +++ b/library/cpp/ytalloc/api/fallback.cpp @@ -107,9 +107,9 @@ Y_WEAK void EnableLogging(TLogHandler /*logHandler*/) Y_WEAK void SetBacktraceProvider(TBacktraceProvider /*provider*/) { } -Y_WEAK void SetBacktraceFormatter(TBacktraceFormatter /*formatter*/) -{ } - +Y_WEAK void SetBacktraceFormatter(TBacktraceFormatter /*formatter*/) +{ } + //////////////////////////////////////////////////////////////////////////////// Y_WEAK void EnableStockpile() diff --git a/library/cpp/ytalloc/api/ytalloc.h b/library/cpp/ytalloc/api/ytalloc.h index d942dde638..860998ba84 100644 --- a/library/cpp/ytalloc/api/ytalloc.h +++ b/library/cpp/ytalloc/api/ytalloc.h @@ -177,12 +177,12 @@ using TBacktraceProvider = int(*)(void** frames, int maxFrames, int skipFrames); void SetBacktraceProvider(TBacktraceProvider provider); using TBacktraceFormatter = TString(*)(const void* const* frames, int frameCount); - -// Sets the callback used for formatting backtraces during large arena mmap calls -// to help detect memory leaks. Can be called multiple times (but calls to the -// previous incarnations of the provider are racy). -void SetBacktraceFormatter(TBacktraceFormatter provider); - + +// Sets the callback used for formatting backtraces during large arena mmap calls +// to help detect memory leaks. Can be called multiple times (but calls to the +// previous incarnations of the provider are racy). +void SetBacktraceFormatter(TBacktraceFormatter provider); + //////////////////////////////////////////////////////////////////////////////// // Misc |