Skip to content

Commit

Permalink
use min_element
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb committed Dec 19, 2024
1 parent 3e2324c commit e29f989
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pdns/dnspacket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,11 @@ bool DNSPacket::couldBeCached() const

unsigned int DNSPacket::getMinTTL()
{
unsigned int minttl = UINT_MAX;
for(const DNSZoneRecord& rr : d_rrs) {
minttl = std::min(minttl, rr.dr.d_ttl);
auto it = std::min_element(d_rrs.begin(), d_rrs.end());

Check warning on line 247 in pdns/dnspacket.cc

View workflow job for this annotation

GitHub Actions / Analyze (cpp, auth)

variable name 'it' is too short, expected at least 3 characters (readability-identifier-length - Level=Warning)
if (it != d_rrs.end()) {
return it->dr.d_ttl;
}

return minttl;
return UINT_MAX;
}

bool DNSPacket::isEmpty()
Expand Down
4 changes: 4 additions & 0 deletions pdns/dnsparser.hh
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ struct DNSZoneRecord
bool auth{true};
bool disabled{false};
DNSRecord dr;

bool operator<(const DNSZoneRecord& other) const {
return dr.d_ttl < other.dr.d_ttl;
}
};

class UnknownRecordContent : public DNSRecordContent
Expand Down

0 comments on commit e29f989

Please sign in to comment.