From 08c852026ddaa1ae7717aa31950946c9da457f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Tue, 7 Feb 2023 13:57:20 +0200 Subject: 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". --- sql/sql_lex.h | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'sql/sql_lex.h') diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 7545a9c4ead..3545a4e8d74 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1705,8 +1705,8 @@ public: These constructor and destructor serve for creation/destruction of Query_tables_list instances which are used as backup storage. */ - Query_tables_list() {} - ~Query_tables_list() {} + Query_tables_list() = default; + ~Query_tables_list() = default; /* Initializes (or resets) Query_tables_list object for "real" use. */ void reset_query_tables_list(bool init); @@ -2364,13 +2364,9 @@ class Lex_input_stream const char *str, const char *end, int sep); my_charset_conv_wc_mb get_escape_func(THD *thd, my_wc_t sep) const; public: - Lex_input_stream() - { - } + Lex_input_stream() = default; - ~Lex_input_stream() - { - } + ~Lex_input_stream() = default; /** Object initializer. Must be called before usage. @@ -2962,7 +2958,7 @@ public: protected: bool save_explain_data_intern(MEM_ROOT *mem_root, Explain_update *eu, bool is_analyze); public: - virtual ~Update_plan() {} + virtual ~Update_plan() = default; Update_plan(MEM_ROOT *mem_root_arg) : impossible_where(false), no_partitions(false), @@ -3016,7 +3012,7 @@ enum password_exp_type struct Account_options: public USER_RESOURCES { - Account_options() { } + Account_options() = default; void reset() { @@ -4653,14 +4649,13 @@ class Set_signal_information { public: /** Empty default constructor, use clear() */ - Set_signal_information() {} + Set_signal_information() = default; /** Copy constructor. */ Set_signal_information(const Set_signal_information& set); /** Destructor. */ - ~Set_signal_information() - {} + ~Set_signal_information() = default; /** Clear all items. */ void clear(); @@ -4783,8 +4778,7 @@ public: return m_lip.init(thd, buff, length); } - ~Parser_state() - {} + ~Parser_state() = default; Lex_input_stream m_lip; Yacc_state m_yacc; -- cgit v1.2.1