Skip to content

Commit

Permalink
Fix clang-tidy warnings for a batch of files (#3213)
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonly authored Oct 18, 2021
1 parent 7ef01da commit b6bbd63
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
8 changes: 3 additions & 5 deletions dbms/src/Common/Arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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))
Expand All @@ -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<char *>(std::align(alignment, size, head_pos, space));
auto * res = static_cast<char *>(std::align(alignment, size, head_pos, space));
if (res)
{
head->pos = static_cast<char *>(head_pos);
Expand Down
6 changes: 3 additions & 3 deletions dbms/src/Common/ArenaWithFreeLists.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ArenaWithFreeLists : private Allocator<false>
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)
Expand All @@ -64,7 +64,7 @@ class ArenaWithFreeLists : private Allocator<false>
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;
}
Expand All @@ -83,7 +83,7 @@ class ArenaWithFreeLists : private Allocator<false>

/// 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<Block *>(ptr);
free_block_ptr->next = old_head;
}
Expand Down
4 changes: 2 additions & 2 deletions dbms/src/Common/ArrayCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class ArrayCache : private boost::noncopyable
/// Represents pending insertion attempt.
struct InsertToken
{
InsertToken(ArrayCache & cache_)
explicit InsertToken(ArrayCache & cache_)
: cache(cache_)
{}

Expand Down Expand Up @@ -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_)
{
}
Expand Down
8 changes: 4 additions & 4 deletions dbms/src/Common/AutoArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class AutoArray

size_t size() const
{
return m_size();
return mSize();
}

bool empty() const
Expand Down Expand Up @@ -208,12 +208,12 @@ class AutoArray
private:
char * data;

size_t & m_size()
size_t & mSize()
{
return reinterpret_cast<size_t *>(data)[-1];
}

size_t m_size() const
size_t mSize() const
{
return reinterpret_cast<const size_t *>(data)[-1];
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b6bbd63

Please sign in to comment.