Skip to content

Commit

Permalink
clang-tidy: simplify some algorithms
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Dec 12, 2024
1 parent 4f6f54c commit 34f7f05
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pdns/arguments.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ bool ArgvMap::contains(const string& var, const string& val)
vector<string> parts;

stringtok(parts, param->second, ", \t");
return std::any_of(parts.begin(), parts.end(), [&](const std::string& str) { return str == val; });
return std::find(parts.begin(), parts.end(), val) != parts.end();
}

string ArgvMap::helpstring(string prefix)
Expand Down
3 changes: 1 addition & 2 deletions pdns/dnsbulktest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ try
pos=split.second.find('/');
if(pos != string::npos) // alexa has whole urls in the list now.
split.second.resize(pos);
if(find_if(split.second.begin(), split.second.end(), isalpha) == split.second.end())
{
if (std::none_of(split.second.begin(), split.second.end(), isalpha)) {
continue; // this was an IP address
}
domains.push_back(TypedQuery(split.second, qtype));
Expand Down
6 changes: 1 addition & 5 deletions pdns/dnsrecords.cc
Original file line number Diff line number Diff line change
Expand Up @@ -812,11 +812,7 @@ SvcParam SVCBBaseRecordContent::getParam(const SvcParam::SvcParamKey &key) const
}

set<SvcParam>::const_iterator SVCBBaseRecordContent::getParamIt(const SvcParam::SvcParamKey &key) const {
auto p = std::find_if(d_params.begin(), d_params.end(),
[&key](const SvcParam &param) {
return param.getKey() == key;
});
return p;
return std::find(d_params.begin(), d_params.end(), key);
}

std::shared_ptr<SVCBBaseRecordContent> SVCBRecordContent::clone() const
Expand Down
5 changes: 5 additions & 0 deletions pdns/svc-records.hh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ class SvcParam {

bool operator< (const SvcParam &other) const;

bool operator==(const SvcParamKey& key) const
{
return key == d_key;
}

SvcParamKey getKey() const {
return d_key;
}
Expand Down

0 comments on commit 34f7f05

Please sign in to comment.