Skip to content

Commit 1977fed

Browse files
committed
Bug#37471922: Auto-fix clang-tidy warnings [57/n] [noclose]
Generate fixes for a number of warnings that clang-tidy can fix automatically. This commit fixes the warning 'modernize-use-emplace'. Change example: - registrations.push_back(Registration(callbacks, handle)); + registrations.emplace_back(callbacks, handle); Change-Id: I682ffa32530f08b0e4f25cc16cba9fd6b5517477
1 parent 62a3da3 commit 1977fed

File tree

15 files changed

+260
-271
lines changed

15 files changed

+260
-271
lines changed

client/check/mysqlcheck.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ int main(int argc, char **argv) {
533533
// Sun Studio does not work with range constructor from char** to string.
534534
vector<string> conv;
535535
conv.reserve(argc);
536-
for (int i = 0; i < argc; i++) conv.push_back(argv[i]);
536+
for (int i = 0; i < argc; i++) conv.emplace_back(argv[i]);
537537

538538
mysql_check(sock, what_to_do, opt_alldbs, opt_check_only_changed,
539539
opt_extended, opt_databases, opt_fast, opt_medium_check,

client/check/mysqlcheck_core.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static int process_all_tables_in_db(const string &database) {
172172
/* Skip views if we don't perform renaming. */
173173
if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0)) continue;
174174

175-
table_names.push_back(row[0]);
175+
table_names.emplace_back(row[0]);
176176
}
177177
mysql_free_result(res);
178178

@@ -294,7 +294,7 @@ static void print_result() {
294294
strcmp(row[3], "OK") != 0) {
295295
if (table_rebuild) {
296296
if (prev_alter[0])
297-
alter_table_cmds.push_back(prev_alter);
297+
alter_table_cmds.emplace_back(prev_alter);
298298
else
299299
tables4rebuild.push_back(escape_db_table_name(prev, dot_pos));
300300
} else {
@@ -346,7 +346,7 @@ static void print_result() {
346346
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR) {
347347
if (table_rebuild) {
348348
if (prev_alter[0])
349-
alter_table_cmds.push_back(prev_alter);
349+
alter_table_cmds.emplace_back(prev_alter);
350350
else
351351
tables4rebuild.push_back(escape_db_table_name(prev, dot_pos));
352352
} else {

components/test/perfschema/test_pfs_notification.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ bool test_pfs_notification() {
484484
if (handle == 0) {
485485
print_log("register_notification() failed");
486486
} else {
487-
registrations.push_back(Registration(callbacks, handle));
487+
registrations.emplace_back(callbacks, handle);
488488
ss << "register_notification " << handle;
489489
print_log(ss.str());
490490
}

components/test/test_mysql_thd_store_service.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ namespace test_mysql_thd_store_service {
4141
class Test_mysql_thd_data final {
4242
public:
4343
Test_mysql_thd_data() {
44-
vector_.push_back("Quick ");
45-
vector_.push_back("Brown ");
46-
vector_.push_back("Fox ");
47-
vector_.push_back("Jumped ");
48-
vector_.push_back("Over ");
49-
vector_.push_back("The ");
50-
vector_.push_back("Lazy ");
51-
vector_.push_back("Dog.");
44+
vector_.emplace_back("Quick ");
45+
vector_.emplace_back("Brown ");
46+
vector_.emplace_back("Fox ");
47+
vector_.emplace_back("Jumped ");
48+
vector_.emplace_back("Over ");
49+
vector_.emplace_back("The ");
50+
vector_.emplace_back("Lazy ");
51+
vector_.emplace_back("Dog.");
5252
}
5353

5454
bool sanity(const std::string &expected) {

plugin/group_replication/libmysqlgcs/src/bindings/xcom/gcs_message_stages.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ std::pair<bool, Gcs_packet> Gcs_message_pipeline::create_packet(
263263

264264
for (auto const &stage_code : stages_to_apply) {
265265
Gcs_message_stage &stage = *retrieve_stage(stage_code);
266-
dynamic_headers.push_back(Gcs_dynamic_header(stage_code, 0));
266+
dynamic_headers.emplace_back(stage_code, 0);
267267
stage_headers.push_back(stage.get_stage_header());
268268
}
269269

plugin/group_replication/libmysqlgcs/src/bindings/xcom/gcs_xcom_communication_interface.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,7 @@ void Gcs_xcom_communication::buffer_incoming_packet(
217217

218218
MYSQL_GCS_LOG_TRACE("Buffering packet cargo=%u", packet.get_cargo_type());
219219

220-
m_buffered_packets.push_back(
221-
std::make_pair(std::move(packet), std::move(xcom_nodes)));
220+
m_buffered_packets.emplace_back(std::move(packet), std::move(xcom_nodes));
222221
}
223222

224223
void Gcs_xcom_communication::deliver_buffered_packets() {

plugin/group_replication/libmysqlgcs/src/bindings/xcom/gcs_xcom_networking.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ bool resolve_all_ip_addr_from_hostname(
331331

332332
if (!inet_ntop(sa->sa_family, in_addr, cip, cip_len)) goto end;
333333

334-
ips.push_back(std::make_pair(sa->sa_family, std::string(cip)));
334+
ips.emplace_back(sa->sa_family, std::string(cip));
335335

336336
addrinfo_list = addrinfo_list->ai_next;
337337
}

plugin/group_replication/src/sql_service/sql_resultset.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ void Sql_resultset::clear() {
127127
m_killed = false;
128128
}
129129

130-
void Sql_resultset::new_row() {
131-
result_value.push_back(std::vector<Field_value *>());
132-
}
130+
void Sql_resultset::new_row() { result_value.emplace_back(); }
133131

134132
void Sql_resultset::new_field(Field_value *val) {
135133
result_value[num_rows].push_back(val);

plugin/test_service_sql_api/test_sql_stmt.cc

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static int handle_start_column_metadata(void *pctx, uint num_cols, uint,
317317
DBUG_PRINT("info", ("resultcs->csname: %s", resultcs->csname));
318318
DBUG_PRINT("info", ("resultcs->m_coll_name: %s", resultcs->m_coll_name));
319319

320-
ctx->tables.push_back(Table(num_cols, resultcs));
320+
ctx->tables.emplace_back(num_cols, resultcs);
321321
ctx->current_col = 0;
322322

323323
return false;
@@ -340,10 +340,10 @@ static int handle_send_column_metadata(void *pctx, struct st_send_field *field,
340340
DBUG_PRINT("info", ("field->decimals: %d", (int)field->decimals));
341341
DBUG_PRINT("info", ("field->type: %d", (int)field->type));
342342

343-
ctx->tables.back().columns.push_back(
344-
Column(field->db_name, field->table_name, field->org_table_name,
345-
field->col_name, field->org_col_name, field->length,
346-
field->charsetnr, field->flags, field->decimals, field->type));
343+
ctx->tables.back().columns.emplace_back(
344+
field->db_name, field->table_name, field->org_table_name, field->col_name,
345+
field->org_col_name, field->length, field->charsetnr, field->flags,
346+
field->decimals, field->type);
347347
ctx->current_col++;
348348
return false;
349349
}
@@ -406,7 +406,7 @@ static int handle_store_null(void *pctx) {
406406
DBUG_TRACE;
407407
const uint col = ctx->current_col;
408408
ctx->current_col++;
409-
ctx->tables.back().columns[col].row_values.push_back("[NULL]");
409+
ctx->tables.back().columns[col].row_values.emplace_back("[NULL]");
410410

411411
return false;
412412
}
@@ -420,8 +420,7 @@ static int handle_store_integer(void *pctx, longlong value) {
420420

421421
const size_t len = snprintf(buffer, sizeof(buffer), "%lld", value);
422422

423-
ctx->tables.back().columns[col].row_values.push_back(
424-
std::string(buffer, len));
423+
ctx->tables.back().columns[col].row_values.emplace_back(buffer, len);
425424

426425
return false;
427426
}
@@ -436,8 +435,7 @@ static int handle_store_longlong(void *pctx, longlong value, uint is_unsigned) {
436435
const size_t len =
437436
snprintf(buffer, sizeof(buffer), is_unsigned ? "%llu" : "%lld", value);
438437

439-
ctx->tables.back().columns[col].row_values.push_back(
440-
std::string(buffer, len));
438+
ctx->tables.back().columns[col].row_values.emplace_back(buffer, len);
441439

442440
return false;
443441
}
@@ -458,8 +456,7 @@ static int handle_store_decimal(void *pctx, const decimal_t *value) {
458456

459457
int len = SIZEOF_SQL_STR_VALUE;
460458
test_decimal_as_string(buffer, value, &len);
461-
ctx->tables.back().columns[col].row_values.push_back(
462-
std::string(buffer, len));
459+
ctx->tables.back().columns[col].row_values.emplace_back(buffer, len);
463460

464461
return false;
465462
}
@@ -472,8 +469,7 @@ static int handle_store_double(void *pctx, double value, uint32) {
472469
ctx->current_col++;
473470

474471
const size_t len = snprintf(buffer, sizeof(buffer), "%3.7g", value);
475-
ctx->tables.back().columns[col].row_values.push_back(
476-
std::string(buffer, len));
472+
ctx->tables.back().columns[col].row_values.emplace_back(buffer, len);
477473

478474
return false;
479475
}
@@ -489,8 +485,7 @@ static int handle_store_date(void *pctx, const MYSQL_TIME *value) {
489485
snprintf(buffer, sizeof(buffer), "%s%4d-%02d-%02d", value->neg ? "-" : "",
490486
value->year, value->month, value->day);
491487

492-
ctx->tables.back().columns[col].row_values.push_back(
493-
std::string(buffer, len));
488+
ctx->tables.back().columns[col].row_values.emplace_back(buffer, len);
494489

495490
return false;
496491
}
@@ -506,8 +501,7 @@ static int handle_store_time(void *pctx, const MYSQL_TIME *value, uint) {
506501
buffer, sizeof(buffer), "%s%02d:%02d:%02d", value->neg ? "-" : "",
507502
value->day ? (value->day * 24 + value->hour) : value->hour, value->minute,
508503
value->second);
509-
ctx->tables.back().columns[col].row_values.push_back(
510-
std::string(buffer, len));
504+
ctx->tables.back().columns[col].row_values.emplace_back(buffer, len);
511505
return false;
512506
}
513507

@@ -523,8 +517,7 @@ static int handle_store_datetime(void *pctx, const MYSQL_TIME *value, uint) {
523517
value->neg ? "-" : "", value->year, value->month, value->day,
524518
value->hour, value->minute, value->second);
525519

526-
ctx->tables.back().columns[col].row_values.push_back(
527-
std::string(buffer, len));
520+
ctx->tables.back().columns[col].row_values.emplace_back(buffer, len);
528521

529522
return false;
530523
}
@@ -536,8 +529,7 @@ static int handle_store_string(void *pctx, const char *const value,
536529
const uint col = ctx->current_col;
537530
ctx->current_col++;
538531

539-
ctx->tables.back().columns[col].row_values.push_back(
540-
std::string(value, length));
532+
ctx->tables.back().columns[col].row_values.emplace_back(value, length);
541533

542534
return false;
543535
}

plugin/x/src/io/xpl_listener_tcp.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ class Tcp_creator {
6767

6868
if (BIND_ALL_ADDRESSES == bind_address) {
6969
bind_addresses.clear();
70-
bind_addresses.push_back(BIND_IPv4_ADDRESS);
70+
bind_addresses.emplace_back(BIND_IPv4_ADDRESS);
7171

7272
if (is_ipv6_avaiable()) {
7373
log_info(ER_XPLUGIN_IPv6_AVAILABLE);
74-
bind_addresses.push_back(BIND_IPv6_ADDRESS);
74+
bind_addresses.emplace_back(BIND_IPv6_ADDRESS);
7575
}
7676
}
7777

router/src/router/src/common/log_filter.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ std::string LogFilter::filter(std::string statement) const {
4343

4444
void LogFilter::add_pattern(const std::string &pattern,
4545
const std::string &replacement) {
46-
patterns_.push_back(std::make_pair(
47-
std::regex(pattern, std::regex_constants::icase), replacement));
46+
patterns_.emplace_back(std::regex(pattern, std::regex_constants::icase),
47+
replacement);
4848
}
4949

5050
void SQLLogFilter::add_default_sql_patterns() {

0 commit comments

Comments
 (0)