]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
clang-tidy: use '' with single character find
authorRosen Penev <rosenp@gmail.com>
Thu, 5 Nov 2020 08:51:24 +0000 (00:51 -0800)
committerRosen Penev <rosenp@gmail.com>
Fri, 5 Feb 2021 01:23:20 +0000 (17:23 -0800)
Found with performance-faster-string-find

Signed-off-by: Rosen Penev <rosenp@gmail.com>
pdns/arguments.cc
pdns/dns.cc
pdns/dnsbackend.cc
pdns/dnsrecords.cc
pdns/ueberbackend.cc

index 6cc6e801b3e0535152a93d9188578d609e33a66d..4a8c69b03b156a8a8e0e9fc7e373ff43ed07ffc7 100644 (file)
@@ -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]))
index b560e59fb86195d721d0cf42ac4a0c27b4660cb0..4bdd409d80b64f88eee2225beb7b0795dde89f17 100644 (file)
@@ -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++)
index ab7a32e172e562bfc138c5aa9deed8836833d2fc..0e5d82ca9b1341069747b514163960249872d5d4 100644 (file)
@@ -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);
index 2a668c3b32edba652c7e4bb0b8dc9b3914cdd1d1..b07a1a2aa9e22b5a0f41ef498c00c94934dface8 100644 (file)
@@ -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");
   }
 
index 13ad0581400bcf87c9bcf1567db6846b3a9eea85..8dc738265887ad9e14cd6993736afb5fceda66fc 100644 (file)
@@ -78,7 +78,7 @@ bool UeberBackend::loadModules(const vector<string>& 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