Skip to content

Commit 08c8520

Browse files
committed
Apply clang-tidy to remove empty constructors / destructors
This patch is the result of running run-clang-tidy -fix -header-filter=.* -checks='-*,modernize-use-equals-default' . Code style changes have been done on top. The result of this change leads to the following improvements: 1. Binary size reduction. * For a -DBUILD_CONFIG=mysql_release build, the binary size is reduced by ~400kb. * A raw -DCMAKE_BUILD_TYPE=Release reduces the binary size by ~1.4kb. 2. Compiler can better understand the intent of the code, thus it leads to more optimization possibilities. Additionally it enabled detecting unused variables that had an empty default constructor but not marked so explicitly. Particular change required following this patch in sql/opt_range.cc result_keys, an unused template class Bitmap now correctly issues unused variable warnings. Setting Bitmap template class constructor to default allows the compiler to identify that there are no side-effects when instantiating the class. Previously the compiler could not issue the warning as it assumed Bitmap class (being a template) would not be performing a NO-OP for its default constructor. This prevented the "unused variable warning".
1 parent 8dab661 commit 08c8520

File tree

242 files changed

+1101
-1341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+1101
-1341
lines changed

client/mysqlbinlog.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ class Load_log_processor
303303
}
304304

305305
public:
306-
Load_log_processor() {}
307-
~Load_log_processor() {}
306+
Load_log_processor() = default;
307+
~Load_log_processor() = default;
308308

309309
int init()
310310
{

include/ilist.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727
// Derive your class from this struct to insert to a linked list.
2828
template <class Tag= void> struct ilist_node
2929
{
30-
ilist_node() noexcept
3130
#ifndef DBUG_OFF
32-
: next(NULL), prev(NULL)
31+
ilist_node() noexcept : next(NULL), prev(NULL) {}
32+
#else
33+
ilist_node() = default;
3334
#endif
34-
{
35-
}
3635

3736
ilist_node(ilist_node *next, ilist_node *prev) noexcept
3837
: next(next), prev(prev)

include/my_atomic_wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ template <typename Type> class Atomic_relaxed
3939
Atomic_relaxed(const Atomic_relaxed<Type> &rhs)
4040
{ m.store(rhs, std::memory_order_relaxed); }
4141
Atomic_relaxed(Type val) : m(val) {}
42-
Atomic_relaxed() {}
42+
Atomic_relaxed() = default;
4343

4444
operator Type() const { return m.load(std::memory_order_relaxed); }
4545
Type operator=(const Type val)

include/my_counter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ template <typename Type> class Atomic_counter
3131
Atomic_counter(const Atomic_counter<Type> &rhs)
3232
{ m_counter.store(rhs, std::memory_order_relaxed); }
3333
Atomic_counter(Type val): m_counter(val) {}
34-
Atomic_counter() {}
34+
Atomic_counter() = default;
3535

3636
Type operator++(int) { return add(1); }
3737
Type operator--(int) { return sub(1); }

include/span.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ template <class ElementType> class span
8181

8282
span(const span &other) : data_(other.data_), size_(other.size_) {}
8383

84-
~span(){};
84+
~span() = default;
8585

8686
span &operator=(const span &other)
8787
{

mysys_ssl/my_crypt.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class MyCTX_nopad : public MyCTX
104104
uchar oiv[MY_AES_BLOCK_SIZE];
105105

106106
MyCTX_nopad() : MyCTX() { }
107-
~MyCTX_nopad() { }
107+
~MyCTX_nopad() = default;
108108

109109
int init(const EVP_CIPHER *cipher, int encrypt, const uchar *key, uint klen,
110110
const uchar *iv, uint ivlen)

plugin/handler_socket/handlersocket/database.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ database::database(const config& c)
189189
{
190190
}
191191

192-
database::~database()
193-
{
194-
}
192+
database::~database() = default;
195193

196194
dbcontext_ptr
197195
database::create_context(bool for_write) volatile
@@ -226,9 +224,7 @@ dbcontext::dbcontext(volatile database *d, bool for_write)
226224
user_level_lock_timeout = d->get_conf().get_int("wrlock_timeout", 12);
227225
}
228226

229-
dbcontext::~dbcontext()
230-
{
231-
}
227+
dbcontext::~dbcontext() = default;
232228

233229
namespace {
234230

plugin/handler_socket/handlersocket/database.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct dbcontext_i;
2727
typedef std::auto_ptr<dbcontext_i> dbcontext_ptr;
2828

2929
struct database_i {
30-
virtual ~database_i() { }
30+
virtual ~database_i() = default;
3131
virtual dbcontext_ptr create_context(bool for_write) volatile = 0;
3232
virtual void stop() volatile = 0;
3333
virtual const config& get_conf() const volatile = 0;
@@ -57,7 +57,7 @@ struct prep_stmt {
5757
};
5858

5959
struct dbcallback_i {
60-
virtual ~dbcallback_i () { }
60+
virtual ~dbcallback_i() = default;
6161
virtual void dbcb_set_prep_stmt(size_t pst_id, const prep_stmt& v) = 0;
6262
virtual const prep_stmt *dbcb_get_prep_stmt(size_t pst_id) const = 0;
6363
virtual void dbcb_resp_short(uint32_t code, const char *msg) = 0;
@@ -111,7 +111,7 @@ struct cmd_exec_args {
111111
};
112112

113113
struct dbcontext_i {
114-
virtual ~dbcontext_i() { }
114+
virtual ~dbcontext_i() = default;
115115
virtual void init_thread(const void *stack_bottom,
116116
volatile int& shutdown_flag) = 0;
117117
virtual void term_thread() = 0;

plugin/handler_socket/handlersocket/hstcpsvr.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct hstcpsvr_i;
4747
typedef std::auto_ptr<hstcpsvr_i> hstcpsvr_ptr;
4848

4949
struct hstcpsvr_i {
50-
virtual ~hstcpsvr_i() { }
50+
virtual ~hstcpsvr_i() = default;
5151
virtual std::string start_listen() = 0;
5252
static hstcpsvr_ptr create(const config& conf);
5353
};

plugin/handler_socket/handlersocket/hstcpsvr_worker.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct hstcpsvr_worker_arg {
2424
};
2525

2626
struct hstcpsvr_worker_i {
27-
virtual ~hstcpsvr_worker_i() { }
27+
virtual ~hstcpsvr_worker_i() = default;
2828
virtual void run() = 0;
2929
static hstcpsvr_worker_ptr create(const hstcpsvr_worker_arg& arg);
3030
};

0 commit comments

Comments
 (0)