From c4caafab2e567b4a3d7b92cdf6b236b7296a15ec Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 5 Dec 2022 16:22:03 +0100 Subject: [PATCH] dnsdist: Refactor AndRule and OrRule to modern C++ loops --- pdns/dnsdistdist/dnsdist-rules.hh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pdns/dnsdistdist/dnsdist-rules.hh b/pdns/dnsdistdist/dnsdist-rules.hh index d43f9dbfd6..885101957b 100644 --- a/pdns/dnsdistdist/dnsdist-rules.hh +++ b/pdns/dnsdistdist/dnsdist-rules.hh @@ -403,11 +403,12 @@ public: bool matches(const DNSQuestion* dq) const override { - auto iter = d_rules.begin(); - for(; iter != d_rules.end(); ++iter) - if(!(*iter)->matches(dq)) - break; - return iter == d_rules.end(); + for (const auto& rule : d_rules) { + if (!rule->matches(dq)) { + return false; + } + } + return true; } string toString() const override @@ -438,10 +439,11 @@ public: bool matches(const DNSQuestion* dq) const override { - auto iter = d_rules.begin(); - for(; iter != d_rules.end(); ++iter) - if((*iter)->matches(dq)) + for (const auto& rule: d_rules) { + if (rule->matches(dq)) { return true; + } + } return false; } -- 2.47.2