]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Two Bucket fields can be const if we take care in the asssignment op. 12193/head
authorOtto Moerbeek <otto@drijf.net>
Mon, 12 Dec 2022 18:59:40 +0000 (19:59 +0100)
committerOtto Moerbeek <otto@drijf.net>
Mon, 12 Dec 2022 18:59:40 +0000 (19:59 +0100)
pdns/histogram.hh

index 931841eb5d60fdc09ff87fabc1b5baa58aa1cb83..4c50789f2871e583a4ef7674e6f16de32f0f922a 100644 (file)
@@ -38,9 +38,18 @@ struct Bucket
 {
   Bucket(std::string name, uint64_t boundary, uint64_t val) :
     d_name(std::move(name)), d_boundary(boundary), d_count(val) {}
-  std::string d_name;
-  uint64_t d_boundary{0};
+  const std::string d_name;
+  const uint64_t d_boundary;
   mutable uint64_t d_count{0};
+
+  Bucket(const Bucket&) = default;
+  Bucket& operator=(const Bucket& rhs)
+  {
+    assert(d_name == rhs.d_name);
+    assert(d_boundary == rhs.d_boundary);
+    d_count = rhs.d_count;
+    return *this;
+  }
 };
 
 struct AtomicBucket