From: Remi Gacogne Date: Mon, 5 Dec 2022 15:22:03 +0000 (+0100) Subject: dnsdist: Refactor AndRule and OrRule to modern C++ loops X-Git-Tag: dnsdist-1.8.0-rc1~198^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F12275%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Refactor AndRule and OrRule to modern C++ loops --- 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; }