diff --git a/dbms/src/Common/Arena.h b/dbms/src/Common/Arena.h index f354ac773dc..7415cde5fbf 100644 --- a/dbms/src/Common/Arena.h +++ b/dbms/src/Common/Arena.h @@ -53,9 +53,7 @@ class Arena : private boost::noncopyable ~Chunk() { Allocator::free(begin, size()); - - if (prev) - delete prev; + delete prev; } size_t size() const { return end - begin; } @@ -101,7 +99,7 @@ class Arena : private boost::noncopyable friend class ArenaAllocator; public: - Arena(size_t initial_size_ = 4096, size_t growth_factor_ = 2, size_t linear_growth_threshold_ = 128 * 1024 * 1024) + explicit Arena(size_t initial_size_ = 4096, size_t growth_factor_ = 2, size_t linear_growth_threshold_ = 128 * 1024 * 1024) : growth_factor(growth_factor_) , linear_growth_threshold(linear_growth_threshold_) , head(new Chunk(initial_size_, nullptr)) @@ -122,7 +120,7 @@ class Arena : private boost::noncopyable void * head_pos = head->pos; size_t space = head->end - head->pos; - auto res = static_cast(std::align(alignment, size, head_pos, space)); + auto * res = static_cast(std::align(alignment, size, head_pos, space)); if (res) { head->pos = static_cast(head_pos); diff --git a/dbms/src/Common/ArenaWithFreeLists.h b/dbms/src/Common/ArenaWithFreeLists.h index bc96951dd4e..0d269472ad6 100644 --- a/dbms/src/Common/ArenaWithFreeLists.h +++ b/dbms/src/Common/ArenaWithFreeLists.h @@ -44,7 +44,7 @@ class ArenaWithFreeLists : private Allocator Block * free_lists[16]{}; public: - ArenaWithFreeLists( + explicit ArenaWithFreeLists( const size_t initial_size = 4096, const size_t growth_factor = 2, const size_t linear_growth_threshold = 128 * 1024 * 1024) @@ -64,7 +64,7 @@ class ArenaWithFreeLists : private Allocator if (auto & free_block_ptr = free_lists[list_idx]) { /// Let's take it. And change the head of the list to the next item in the list. - const auto res = free_block_ptr->data; + auto * const res = free_block_ptr->data; free_block_ptr = free_block_ptr->next; return res; } @@ -83,7 +83,7 @@ class ArenaWithFreeLists : private Allocator /// Insert the released block into the head of the list. auto & free_block_ptr = free_lists[list_idx]; - const auto old_head = free_block_ptr; + auto * const old_head = free_block_ptr; free_block_ptr = reinterpret_cast(ptr); free_block_ptr->next = old_head; } diff --git a/dbms/src/Common/ArrayCache.h b/dbms/src/Common/ArrayCache.h index fd716d1ab95..8110a27c580 100644 --- a/dbms/src/Common/ArrayCache.h +++ b/dbms/src/Common/ArrayCache.h @@ -269,7 +269,7 @@ class ArrayCache : private boost::noncopyable /// Represents pending insertion attempt. struct InsertToken { - InsertToken(ArrayCache & cache_) + explicit InsertToken(ArrayCache & cache_) : cache(cache_) {} @@ -546,7 +546,7 @@ class ArrayCache : private boost::noncopyable public: - ArrayCache(size_t max_total_size_) + explicit ArrayCache(size_t max_total_size_) : max_total_size(max_total_size_) { } diff --git a/dbms/src/Common/AutoArray.h b/dbms/src/Common/AutoArray.h index d7629b9d1dd..eebff46dd7f 100644 --- a/dbms/src/Common/AutoArray.h +++ b/dbms/src/Common/AutoArray.h @@ -99,7 +99,7 @@ class AutoArray size_t size() const { - return m_size(); + return mSize(); } bool empty() const @@ -208,12 +208,12 @@ class AutoArray private: char * data; - size_t & m_size() + size_t & mSize() { return reinterpret_cast(data)[-1]; } - size_t m_size() const + size_t mSize() const { return reinterpret_cast(data)[-1]; } @@ -243,7 +243,7 @@ class AutoArray data = new char[size_ * sizeof(T) + sizeof(size_t)]; data += sizeof(size_t); - m_size() = size_; + mSize() = size_; if (!dont_init_elems) for (size_t i = 0; i < size_; ++i)