From cc1f53903afbf8df8a843e840b3f30ff6580cba0 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Mon, 12 Dec 2022 19:59:40 +0100 Subject: [PATCH] Two Bucket fields can be const if we take care in the asssignment op. --- pdns/histogram.hh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pdns/histogram.hh b/pdns/histogram.hh index 931841eb5d..4c50789f28 100644 --- a/pdns/histogram.hh +++ b/pdns/histogram.hh @@ -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 -- 2.47.2