Skip to content

Commit 112b9b3

Browse files
committed
Bug#37471922: Auto-fix clang-tidy warnings [31/n] [noclose]
Generate fixes for a number of warnings that clang-tidy can fix automatically. This commit fixes the warning 'performance-faster-string-find'. Change example: - std::size_t slash = full.rfind("/"); + std::size_t slash = full.rfind('/'); Change-Id: I312891503a379c1e7c0f665102bfb0624912ff9d
1 parent bb781f5 commit 112b9b3

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

libmysql/authentication_kerberos/gssapi_authentication_client.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ std::string Gssapi_client::get_user_name() {
143143
if (m_kerberos->get_upn(&cached_user_name)) {
144144
size_t pos = std::string::npos;
145145
/* Remove realm */
146-
if ((pos = cached_user_name.find("@")) != std::string::npos) {
146+
if ((pos = cached_user_name.find('@')) != std::string::npos) {
147147
log_client_dbg("Trimming realm from upn.");
148148
cached_user_name.erase(pos, cached_user_name.length() - pos + 1);
149149
}

libmysql/authentication_ldap/auth_ldap_kerberos.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ bool Kerberos::get_kerberos_config() {
336336

337337
/* IPV6 */
338338
if (m_ldap_server_host[0] == '[') {
339-
auto pos = m_ldap_server_host.find("]");
339+
auto pos = m_ldap_server_host.find(']');
340340
if (pos != m_ldap_server_host.npos &&
341341
(m_ldap_server_host.length() > (pos + 1)) &&
342342
(m_ldap_server_host[pos + 1] == ':')) {
@@ -345,7 +345,7 @@ bool Kerberos::get_kerberos_config() {
345345
}
346346
/* IPV4 */
347347
else {
348-
auto pos = m_ldap_server_host.find(":");
348+
auto pos = m_ldap_server_host.find(':');
349349
if (pos != m_ldap_server_host.npos) {
350350
m_ldap_server_host.erase(pos);
351351
}

mysys/my_default.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ void update_variable_source(const char *opt_name, const char *value) {
14971497
/* opt_name must be of form --XXXXX which means min length must be 3 */
14981498
if (var_name.length() < 3) return;
14991499

1500-
std::size_t pos = var_name.find("=");
1500+
std::size_t pos = var_name.find('=');
15011501
/* strip the value part if present */
15021502
if (pos != string::npos) var_name = var_name.substr(0, pos);
15031503

@@ -1508,7 +1508,7 @@ void update_variable_source(const char *opt_name, const char *value) {
15081508
var_name = var_name.substr(2);
15091509

15101510
/* replace all '-' to '_' */
1511-
while ((pos = var_name.find("-")) != string::npos)
1511+
while ((pos = var_name.find('-')) != string::npos)
15121512
var_name.replace(pos, 1, "_");
15131513

15141514
/*
@@ -1575,7 +1575,7 @@ void set_variable_source(const char *opt_name, void *value) {
15751575
std::size_t pos;
15761576

15771577
/* replace all '-' to '_' */
1578-
while ((pos = src_name.find("-")) != string::npos)
1578+
while ((pos = src_name.find('-')) != string::npos)
15791579
src_name.replace(pos, 1, "_");
15801580

15811581
auto it = variables_hash.find(src_name);

plugin/clone/src/clone_plugin.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,13 @@ static bool scan_donor_list(const std::string &donor_list,
188188

189189
try {
190190
/* Don't allow space in donor list. */
191-
auto space_pos = donor_list.find(" ");
191+
auto space_pos = donor_list.find(' ');
192192
if (space_pos != std::string::npos) {
193193
return (false);
194194
}
195195
/* Scan through all entries. */
196196
while (comma_pos != std::string::npos) {
197-
comma_pos = donor_list.find(",", begin_pos);
197+
comma_pos = donor_list.find(',', begin_pos);
198198
auto entry_len = comma_pos;
199199

200200
if (entry_len != std::string::npos) {
@@ -206,7 +206,7 @@ static bool scan_donor_list(const std::string &donor_list,
206206
}
207207

208208
const std::string entry = donor_list.substr(begin_pos, entry_len);
209-
auto colon_pos = entry.find(":");
209+
auto colon_pos = entry.find(':');
210210

211211
/* Bad entry if no separator is found or found in beginning. */
212212
if (colon_pos == std::string::npos || colon_pos == 0) {

plugin/group_replication/libmysqlgcs/src/interface/gcs_logging.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ bool Gcs_debug_options::get_debug_options(const std::string &debug_options,
175175
return true;
176176
}
177177

178-
if (!match && (debug_options.find(",") != std::string::npos)) return true;
178+
if (!match && (debug_options.find(',') != std::string::npos)) return true;
179179

180180
return false;
181181
}

storage/ndb/ndbapi-examples/ndbapi_array_simple/ndbapi_array_simple.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static int get_string(const NdbRecAttr *attr, string &str) {
125125
str = string(data_start_ptr, attr_bytes);
126126
if (attr->getType() == NdbDictionary::Column::Char) {
127127
/* Fixed Char : remove blank spaces at the end */
128-
size_t endpos = str.find_last_not_of(" ");
128+
size_t endpos = str.find_last_not_of(' ');
129129
if (string::npos != endpos) {
130130
str = str.substr(0, endpos + 1);
131131
}

storage/ndb/tools/ndb_import.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static int checkarg(TableArg &arg, const char *str) {
380380
std::string full = str; // foo/t1.bar.csv
381381
convertpath(full);
382382
std::string base = full; // t1.bar.csv
383-
std::size_t slash = full.rfind("/");
383+
std::size_t slash = full.rfind('/');
384384
if (slash != std::string::npos) {
385385
base = full.substr(slash + 1);
386386
}
@@ -392,13 +392,13 @@ static int checkarg(TableArg &arg, const char *str) {
392392
}
393393
CHK1(ret == 0);
394394
std::string stem = base; // t1.bar
395-
std::size_t rdot = base.rfind(".");
395+
std::size_t rdot = base.rfind('.');
396396
if (rdot != std::string::npos) {
397397
stem = base.substr(0, rdot);
398398
}
399399
if (g_opt.m_table == nullptr) {
400400
std::string table = stem; // t1
401-
std::size_t ldot = stem.find(".");
401+
std::size_t ldot = stem.find('.');
402402
if (ldot != std::string::npos) {
403403
table = stem.substr(0, ldot);
404404
}

0 commit comments

Comments
 (0)