]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Prefer const references where applicable to avoid unnecessary data copying
authorCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Thu, 13 Dec 2018 14:24:46 +0000 (15:24 +0100)
committerCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Fri, 14 Dec 2018 08:49:24 +0000 (09:49 +0100)
pdns/filterpo.cc
pdns/histog.hh
pdns/lazy_allocator.hh
pdns/rpzloader.cc
pdns/rpzloader.hh

index 90179584ae6a9253b7825ebf2b2fef9702bd102d..5c7360028160ac2389c09efe44b3e22bde8199e7 100644 (file)
@@ -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<const uint8_t*>(&addr.sin4.sin_addr.s_addr);
index f96e4beab0fd280084ff56517b47862d427ebfd4..62df2a8fe1d72bc965c504274ff3a78e8691ab68 100644 (file)
@@ -21,7 +21,7 @@ struct LogHistogramBin
 
 template<typename T>
 std::vector<LogHistogramBin> createLogHistogram(const T& bins,
-                        std::deque<double> 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<double>& 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<LogHistogramBin> createLogHistogram(const T& bins,
 }
 
 template<typename T>
-void writeLogHistogramFile(const T& bins, std::ostream& out, std::deque<double> 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<double>& 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);
index 1b9308851a449b275e1f696fa884af8c3b7df0f8..17ef07aa6749072986eeddc6044a85eb226fa2d2 100644 (file)
@@ -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<pointer>(::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
index eaa258b7b5d141f7f83007a142057f81198eb1f8..0e248a7fe952372e7dc0364b8dab87970cb3ff2b 100644 (file)
@@ -338,7 +338,7 @@ static bool dumpZoneToDisk(const DNSName& zoneName, const std::shared_ptr<DNSFil
   return true;
 }
 
-void RPZIXFRTracker(const std::vector<ComboAddress> masters, boost::optional<DNSFilterEngine::Policy> defpol, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout, std::shared_ptr<SOARecordContent> sr, std::string dumpZoneFileName, uint64_t configGeneration)
+void RPZIXFRTracker(const std::vector<ComboAddress>& masters, boost::optional<DNSFilterEngine::Policy> defpol, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout, std::shared_ptr<SOARecordContent> sr, std::string dumpZoneFileName, uint64_t configGeneration)
 {
   setThreadName("pdns-r/RPZIXFR");
   bool isPreloaded = sr != nullptr;
index b29f145011e127bb8d9160e14b2217d06c44a684..b167ee7f19a2d0217ff33daa1d6a043112a85b1a 100644 (file)
@@ -28,7 +28,7 @@ extern bool g_logRPZChanges;
 
 std::shared_ptr<SOARecordContent> loadRPZFromFile(const std::string& fname, std::shared_ptr<DNSFilterEngine::Zone> zone, boost::optional<DNSFilterEngine::Policy> defpol, uint32_t maxTTL);
 void RPZRecordToPolicy(const DNSRecord& dr, std::shared_ptr<DNSFilterEngine::Zone> zone, bool addOrRemove, boost::optional<DNSFilterEngine::Policy> defpol, uint32_t maxTTL);
-void RPZIXFRTracker(const std::vector<ComboAddress> master, boost::optional<DNSFilterEngine::Policy> defpol, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout, shared_ptr<SOARecordContent> sr, std::string dumpZoneFileName, uint64_t configGeneration);
+void RPZIXFRTracker(const std::vector<ComboAddress>& masters, boost::optional<DNSFilterEngine::Policy> defpol, uint32_t maxTTL, size_t zoneIdx, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, const uint16_t axfrTimeout, shared_ptr<SOARecordContent> sr, std::string dumpZoneFileName, uint64_t configGeneration);
 
 struct rpzStats
 {