std::max(static_cast<int64_t>(0), static_cast<int64_t>(counter + value));
}
+void
+Counters::increment(const Counters& other)
+{
+ m_counters.resize(std::max(size(), other.size()));
+ for (size_t i = 0; i < other.size(); ++i) {
+ auto& counter = m_counters[i];
+ counter = std::max(static_cast<int64_t>(0),
+ static_cast<int64_t>(counter + other.m_counters[i]));
+ }
+}
+
size_t
Counters::size() const
{
void set_raw(size_t index, uint64_t value);
void increment(Statistic statistic, int64_t value = 1);
+ void increment(const Counters& other);
size_t size() const;
}
stats_read(sfile, counters);
- for (size_t i = 0; i < static_cast<size_t>(Statistic::END); ++i) {
- counters.increment(static_cast<Statistic>(i),
- updates.get(static_cast<Statistic>(i)));
- }
+ counters.increment(updates);
stats_write(sfile, counters);
}