From: Rosen Penev Date: Thu, 5 Nov 2020 08:51:24 +0000 (-0800) Subject: clang-tidy: use '' with single character find X-Git-Tag: dnsdist-1.6.0-alpha2~55^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2e321dadc1834a4176cfe12d233c76da14ce7a42;p=thirdparty%2Fpdns.git clang-tidy: use '' with single character find Found with performance-faster-string-find Signed-off-by: Rosen Penev --- diff --git a/pdns/arguments.cc b/pdns/arguments.cc index 6cc6e801b3..4a8c69b03b 100644 --- a/pdns/arguments.cc +++ b/pdns/arguments.cc @@ -337,12 +337,12 @@ void ArgvMap::parseOne(const string &arg, const string &parseOnly, bool lax) val=arg.substr(pos+2); incremental = true; } - else if(arg.find("--") == 0 && (pos=arg.find("="))!=string::npos) // this is a --port=25 case + else if(arg.find("--") == 0 && (pos=arg.find('='))!=string::npos) // this is a --port=25 case { var=arg.substr(2,pos-2); val=arg.substr(pos+1); } - else if(arg.find("--") == 0 && (arg.find("=")==string::npos)) // this is a --daemon case + else if(arg.find("--") == 0 && (arg.find('=')==string::npos)) // this is a --daemon case { var=arg.substr(2); val=""; @@ -428,7 +428,7 @@ bool ArgvMap::parseFile(const char *fname, const string& arg, bool lax) { line+=pline; // strip everything after a # - if((pos=line.find("#"))!=string::npos) { + if((pos=line.find('#'))!=string::npos) { // make sure it's either first char or has whitespace before // fixes issue #354 if (pos == 0 || std::isspace(line[pos-1])) diff --git a/pdns/dns.cc b/pdns/dns.cc index b560e59fb8..4bdd409d80 100644 --- a/pdns/dns.cc +++ b/pdns/dns.cc @@ -126,7 +126,7 @@ uint32_t hashQuestion(const char* packet, uint16_t len, uint32_t init) string& attodot(string &str) { - if(str.find_first_of("@")==string::npos) + if(str.find_first_of('@')==string::npos) return str; for (unsigned int i = 0; i < str.length(); i++) diff --git a/pdns/dnsbackend.cc b/pdns/dnsbackend.cc index ab7a32e172..0e5d82ca9b 100644 --- a/pdns/dnsbackend.cc +++ b/pdns/dnsbackend.cc @@ -130,7 +130,7 @@ void BackendMakerClass::load(const string &module) { bool res; - if(module.find(".")==string::npos) + if(module.find('.')==string::npos) res=UeberBackend::loadmodule(arg()["module-dir"]+"/lib"+module+"backend.so"); else if(module[0]=='/' || (module[0]=='.' && module[1]=='/') || (module[0]=='.' && module[1]=='.')) // absolute or current path res=UeberBackend::loadmodule(module); diff --git a/pdns/dnsrecords.cc b/pdns/dnsrecords.cc index 2a668c3b32..b07a1a2aa9 100644 --- a/pdns/dnsrecords.cc +++ b/pdns/dnsrecords.cc @@ -568,7 +568,7 @@ APLRDataElement APLRecordContent::parseAPLElement(const string& element) { record = element; } - if (record.find("/") == string::npos) { // Required by RFC section 5 + if (record.find('/') == string::npos) { // Required by RFC section 5 throw MOADNSException("Asked to decode '"+element+"' as an APL record, but missing subnet mask"); } diff --git a/pdns/ueberbackend.cc b/pdns/ueberbackend.cc index 13ad058140..8dc7382658 100644 --- a/pdns/ueberbackend.cc +++ b/pdns/ueberbackend.cc @@ -78,7 +78,7 @@ bool UeberBackend::loadModules(const vector& modules, const string& path { for (const auto& module: modules) { bool res; - if (module.find(".")==string::npos) { + if (module.find('.')==string::npos) { res = UeberBackend::loadmodule(path+"/lib"+module+"backend.so"); } else if (module[0]=='/' || (module[0]=='.' && module[1]=='/') || (module[0]=='.' && module[1]=='.')) { // absolute or current path