summaryrefslogtreecommitdiff
path: root/src/base/statistics.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/statistics.cc')
-rw-r--r--src/base/statistics.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/base/statistics.cc b/src/base/statistics.cc
index a186f9763..5e6882c79 100644
--- a/src/base/statistics.cc
+++ b/src/base/statistics.cc
@@ -203,19 +203,25 @@ validateStatName(const string &name)
void
Info::setName(const string &name)
{
+ setName(nullptr, name);
+}
+
+void
+Info::setName(const Group *parent, const string &name)
+{
if (!validateStatName(name))
panic("invalid stat name '%s'", name);
- pair<NameMapType::iterator, bool> p =
- nameMap().insert(make_pair(name, this));
-
- Info *other = p.first->second;
- bool result = p.second;
+ // We only register the stat with the nameMap() if we are using
+ // old-style stats without a parent group. New-style stats should
+ // be unique since their names should correspond to a member
+ // variable.
+ if (!parent) {
+ auto p = nameMap().insert(make_pair(name, this));
- if (!result) {
- // using other->name instead of just name to avoid a compiler
- // warning. They should be the same.
- panic("same statistic name used twice! name=%s\n", other->name);
+ if (!p.second)
+ panic("same statistic name used twice! name=%s\n",
+ name);
}
this->name = name;