From: Charles-Henri Bruyand Date: Thu, 13 Dec 2018 14:24:46 +0000 (+0100) Subject: Prefer const references where applicable to avoid unnecessary data copying X-Git-Tag: rec-4.2.0-alpha1~49^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cffabb3ba6376a5661a1873cf99867ff81d54f13;p=thirdparty%2Fpdns.git Prefer const references where applicable to avoid unnecessary data copying --- diff --git a/pdns/filterpo.cc b/pdns/filterpo.cc index 90179584ae..5c73600281 100644 --- a/pdns/filterpo.cc +++ b/pdns/filterpo.cc @@ -340,7 +340,7 @@ DNSName DNSFilterEngine::Zone::maskToRPZ(const Netmask& nm) { int bits = nm.getBits(); DNSName res(std::to_string(bits)); - const auto addr = nm.getNetwork(); + const auto& addr = nm.getNetwork(); if (addr.isIPv4()) { const uint8_t* bytes = reinterpret_cast(&addr.sin4.sin_addr.s_addr); diff --git a/pdns/histog.hh b/pdns/histog.hh index f96e4beab0..62df2a8fe1 100644 --- a/pdns/histog.hh +++ b/pdns/histog.hh @@ -21,7 +21,7 @@ struct LogHistogramBin template std::vector createLogHistogram(const T& bins, - std::deque percentiles={0.001, 0.01, 0.1, 0.2, 0.5, 1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 94, 95, 96, 97, 97.5, 98, 98.5, 99, 99.5, 99.6, 99.9, 99.99, 99.999, 99.9999}) + std::deque& percentiles={0.001, 0.01, 0.1, 0.2, 0.5, 1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 94, 95, 96, 97, 97.5, 98, 98.5, 99, 99.5, 99.6, 99.9, 99.99, 99.999, 99.9999}) { uint64_t totcumul=0, sum=0; @@ -60,7 +60,7 @@ std::vector createLogHistogram(const T& bins, } template -void writeLogHistogramFile(const T& bins, std::ostream& out, std::deque percentiles={0.001, 0.01, 0.1, 0.2, 0.5, 1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 94, 95, 96, 97, 97.5, 98, 98.5, 99, 99.5, 99.6, 99.9, 99.99, 99.999, 99.9999} ) +void writeLogHistogramFile(const T& bins, std::ostream& out, std::deque& percentiles={0.001, 0.01, 0.1, 0.2, 0.5, 1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 94, 95, 96, 97, 97.5, 98, 98.5, 99, 99.5, 99.6, 99.9, 99.99, 99.999, 99.9999} ) { auto vec = createLogHistogram(bins, percentiles); diff --git a/pdns/lazy_allocator.hh b/pdns/lazy_allocator.hh index 1b9308851a..17ef07aa67 100644 --- a/pdns/lazy_allocator.hh +++ b/pdns/lazy_allocator.hh @@ -35,12 +35,12 @@ struct lazy_allocator { "lazy_allocator must only be used with trivial types"); pointer - allocate (size_type const n) { + allocate (size_type const& n) { return static_cast(::operator new (n * sizeof(value_type))); } void - deallocate (pointer const ptr, size_type const n) noexcept { + deallocate (pointer const ptr, size_type const& n) noexcept { #if defined(__cpp_sized_deallocation) && (__cpp_sized_deallocation >= 201309) ::operator delete (ptr, n * sizeof(value_type)); #else diff --git a/pdns/rpzloader.cc b/pdns/rpzloader.cc index eaa258b7b5..0e248a7fe9 100644 --- a/pdns/rpzloader.cc +++ b/pdns/rpzloader.cc @@ -338,7 +338,7 @@ static bool dumpZoneToDisk(const DNSName& zoneName, const std::shared_ptr masters, boost::optional defpol, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout, std::shared_ptr sr, std::string dumpZoneFileName, uint64_t configGeneration) +void RPZIXFRTracker(const std::vector& masters, boost::optional defpol, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout, std::shared_ptr sr, std::string dumpZoneFileName, uint64_t configGeneration) { setThreadName("pdns-r/RPZIXFR"); bool isPreloaded = sr != nullptr; diff --git a/pdns/rpzloader.hh b/pdns/rpzloader.hh index b29f145011..b167ee7f19 100644 --- a/pdns/rpzloader.hh +++ b/pdns/rpzloader.hh @@ -28,7 +28,7 @@ extern bool g_logRPZChanges; std::shared_ptr loadRPZFromFile(const std::string& fname, std::shared_ptr zone, boost::optional defpol, uint32_t maxTTL); void RPZRecordToPolicy(const DNSRecord& dr, std::shared_ptr zone, bool addOrRemove, boost::optional defpol, uint32_t maxTTL); -void RPZIXFRTracker(const std::vector master, boost::optional defpol, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout, shared_ptr sr, std::string dumpZoneFileName, uint64_t configGeneration); +void RPZIXFRTracker(const std::vector& masters, boost::optional defpol, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout, shared_ptr sr, std::string dumpZoneFileName, uint64_t configGeneration); struct rpzStats {