1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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".
This commit is contained in:
Vicențiu Ciorbaru
2023-02-07 13:57:20 +02:00
parent 8dab661416
commit 08c852026d
242 changed files with 1101 additions and 1341 deletions

View File

@ -842,7 +842,7 @@ struct xid_t {
long bqual_length;
char data[XIDDATASIZE]; // not \0-terminated !
xid_t() {} /* Remove gcc warning */
xid_t() = default; /* Remove gcc warning */
bool eq(struct xid_t *xid) const
{ return !xid->is_null() && eq(xid->gtrid_length, xid->bqual_length, xid->data); }
bool eq(long g, long b, const char *d) const
@ -1529,7 +1529,7 @@ struct handlerton
public:
virtual bool add_table(const char *tname, size_t tlen) = 0;
virtual bool add_file(const char *fname) = 0;
protected: virtual ~discovered_list() {}
protected: virtual ~discovered_list() = default;
};
/*
@ -1710,7 +1710,7 @@ struct THD_TRANS
m_unsafe_rollback_flags= 0;
}
bool is_empty() const { return ha_list == NULL; }
THD_TRANS() {} /* Remove gcc warning */
THD_TRANS() = default; /* Remove gcc warning */
unsigned int m_unsafe_rollback_flags;
/*
@ -1954,7 +1954,7 @@ struct Table_period_info: Sql_alloc
struct start_end_t
{
start_end_t() {};
start_end_t() = default;
start_end_t(const LEX_CSTRING& _start, const LEX_CSTRING& _end) :
start(_start),
end(_end) {}
@ -2262,9 +2262,9 @@ struct Table_specification_st: public HA_CREATE_INFO,
class inplace_alter_handler_ctx : public Sql_alloc
{
public:
inplace_alter_handler_ctx() {}
inplace_alter_handler_ctx() = default;
virtual ~inplace_alter_handler_ctx() {}
virtual ~inplace_alter_handler_ctx() = default;
virtual void set_shared_data(const inplace_alter_handler_ctx& ctx) {}
};
@ -2490,8 +2490,8 @@ typedef struct st_key_create_information
class TABLEOP_HOOKS
{
public:
TABLEOP_HOOKS() {}
virtual ~TABLEOP_HOOKS() {}
TABLEOP_HOOKS() = default;
virtual ~TABLEOP_HOOKS() = default;
inline void prelock(TABLE **tables, uint count)
{
@ -2532,7 +2532,7 @@ typedef class Item COND;
typedef struct st_ha_check_opt
{
st_ha_check_opt() {} /* Remove gcc warning */
st_ha_check_opt() = default; /* Remove gcc warning */
uint flags; /* isam layer flags (e.g. for myisamchk) */
uint sql_flags; /* sql layer flags - for something myisamchk cannot do */
time_t start_time; /* When check/repair starts */
@ -2911,8 +2911,8 @@ uint calculate_key_len(TABLE *, uint, const uchar *, key_part_map);
class Handler_share
{
public:
Handler_share() {}
virtual ~Handler_share() {}
Handler_share() = default;
virtual ~Handler_share() = default;
};
enum class Compare_keys : uint32_t
@ -4969,7 +4969,7 @@ public:
const LEX_CSTRING *wild_arg);
Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_CSTRING*> *tables_arg)
: thd(thd_arg), wild(NULL), with_temps(true), tables(tables_arg) {}
~Discovered_table_list() {}
~Discovered_table_list() = default;
bool add_table(const char *tname, size_t tlen);
bool add_file(const char *fname);