From: Otto Moerbeek Date: Mon, 4 Nov 2024 08:56:33 +0000 (+0100) Subject: More Tidy X-Git-Tag: rec-5.2.0-alpha1~2^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3cc2c43eb73628e2cbb5dc9437fa5971d0e59e57;p=thirdparty%2Fpdns.git More Tidy --- diff --git a/pdns/recursordist/rec_channel_rec.cc b/pdns/recursordist/rec_channel_rec.cc index 21e9e0a676..29e6efa46b 100644 --- a/pdns/recursordist/rec_channel_rec.cc +++ b/pdns/recursordist/rec_channel_rec.cc @@ -1583,31 +1583,33 @@ static DNSName nopFilter(const DNSName& name) return name; } -static string doGenericTopQueries(pleasequeryfunc_t func, std::function filter = nopFilter) +static string doGenericTopQueries(const pleasequeryfunc_t& func, const std::function& filter = nopFilter) { typedef pair query_t; typedef map counts_t; counts_t counts; - vector queries = broadcastAccFunction>(func); + auto queries = broadcastAccFunction>(func); unsigned int total = 0; - for (const query_t& q : queries) { + for (const auto& query : queries) { total++; - counts[pair(filter(q.first), q.second)]++; + counts[pair(filter(query.first), query.second)]++; } typedef std::multimap rcounts_t; rcounts_t rcounts; - for (auto&& c : counts) - rcounts.emplace(-c.second, c.first); + for (const auto& count : counts) { + rcounts.emplace(-count.second, count.first); + } ostringstream ret; ret << "Over last " << total << " entries:\n"; boost::format fmt("%.02f%%\t%s\n"); - int limit = 0, accounted = 0; - if (total) { - for (rcounts_t::const_iterator i = rcounts.begin(); i != rcounts.end() && limit < 20; ++i, ++limit) { + unsigned int limit = 0; + unsigned int accounted = 0; + if (total > 0) { + for (auto i = rcounts.begin(); i != rcounts.end() && limit < 20; ++i, ++limit) { ret << fmt % (-100.0 * i->first / total) % (i->second.first.toLogString() + "|" + DNSRecordContent::NumberToType(i->second.second)); accounted += -i->first; }